Created
January 1, 2020 15:41
-
-
Save voluntas/5b3fae58736012c5282d38ea2222fe64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"time" | |
"github.com/rs/zerolog" | |
"gopkg.in/natefinch/lumberjack.v2" | |
) | |
func main() { | |
zerolog.TimeFieldFormat = time.RFC3339Nano | |
writer := &lumberjack.Logger{ | |
Filename: "test.log", | |
// メガバイト | |
MaxSize: 10, | |
MaxBackups: 5, | |
// 日 | |
MaxAge: 1, | |
// デフォルトは無効 | |
Compress: true, | |
} | |
log := zerolog.New(writer).With().Logger() | |
log.Log(). | |
Timestamp(). | |
Int("baz", 123). | |
Msg("hello world") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
test.log にこんな感じで記録されていきます。