github.com/v2pro/plz@v0.0.0-20221028024117-e5f9aec5b631/countlog/output/lumberjack/example_test.go (about)

     1  package lumberjack_test
     2  
     3  import (
     4  	"log"
     5  
     6  	"gopkg.in/natefinch/lumberjack.v2"
     7  )
     8  
     9  // To use lumberjack with the standard library's log package, just pass it into
    10  // the SetOutput function when your application starts.
    11  func Example() {
    12  	log.SetOutput(&lumberjack.Logger{
    13  		Filename:   "/var/log/myapp/foo.log",
    14  		MaxSize:    500, // megabytes
    15  		MaxBackups: 3,
    16  		MaxAge:     28, // days
    17  		Compress:   true, // disabled by default
    18  	})
    19  }