-
-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathmain.go
More file actions
30 lines (23 loc) · 542 Bytes
/
Copy pathmain.go
File metadata and controls
30 lines (23 loc) · 542 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package main
import (
"time"
"github.com/kataras/golog"
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
)
/*
go get github.com/lestrrat-go/file-rotatelogs
*/
func main() {
// Read more at: https://github.com/lestrrat-go/file-rotatelogs#synopsis
pathToAccessLog := "./access_log.%Y%m%d%H%M"
w, err := rotatelogs.New(
pathToAccessLog,
rotatelogs.WithMaxAge(24*time.Hour),
rotatelogs.WithRotationTime(time.Hour))
if err != nil {
golog.Fatal(err)
}
defer w.Close()
golog.SetOutput(w)
golog.Println("A Log entry")
}