@@ -39,6 +39,7 @@ method=GET, uri=/, status=200
39
39
## Configuration
40
40
41
41
``` go
42
+ // LoggerConfig defines the config for Logger middleware.
42
43
LoggerConfig struct {
43
44
// Skipper defines a function to skip middleware.
44
45
Skipper Skipper
@@ -49,12 +50,14 @@ LoggerConfig struct {
49
50
// - time_unix_nano
50
51
// - time_rfc3339
51
52
// - time_rfc3339_nano
53
+ // - time_custom
52
54
// - id (Request ID)
53
55
// - remote_ip
54
56
// - uri
55
57
// - host
56
58
// - method
57
59
// - path
60
+ // - protocol
58
61
// - referer
59
62
// - user_agent
60
63
// - status
@@ -66,14 +69,16 @@ LoggerConfig struct {
66
69
// - header:<NAME>
67
70
// - query:<NAME>
68
71
// - form:<NAME>
69
- // - cookie:<NAME>
70
72
//
71
73
// Example "${remote_ip} ${status}"
72
74
//
73
75
// Optional. Default value DefaultLoggerConfig.Format.
74
- Format string ` json :"format"`
76
+ Format string ` yaml :"format"`
75
77
76
- // Output is a writer where logs are written.
78
+ // Optional. Default value DefaultLoggerConfig.CustomTimeFormat.
79
+ CustomTimeFormat string ` yaml:"custom_time_format"`
80
+
81
+ // Output is a writer where logs in JSON format are written.
77
82
// Optional. Default value os.Stdout.
78
83
Output io.Writer
79
84
}
@@ -84,10 +89,10 @@ LoggerConfig struct {
84
89
``` go
85
90
DefaultLoggerConfig = LoggerConfig {
86
91
Skipper : DefaultSkipper ,
87
- Format : ` {"time":"${time_rfc3339_nano}","id":"${id}","remote_ip":"${remote_ip}","host":"${host}", ` +
88
- ` "method ":"${method }","uri ":"${uri }","status":${status},"error":"${error }","latency":${latency} ,` +
89
- ` "latency_human":"${latency_human }","bytes_in ":${bytes_in}, ` +
90
- ` "bytes_out":${bytes_out}}` + " \n " ,
91
- Output : os. Stdout
92
+ Format : ` {"time":"${time_rfc3339_nano}","id":"${id}","remote_ip":"${remote_ip}",` +
93
+ ` "host ":"${host }","method ":"${method }","uri":"${uri }","user_agent":"${user_agent}" ,` +
94
+ ` "status":${status},"error":"${error }","latency ":${latency},"latency_human":"${latency_human}" ` +
95
+ ` ,"bytes_in":${bytes_in}, "bytes_out":${bytes_out}}` + " \n " ,
96
+ CustomTimeFormat : " 2006-01-02 15:04:05.00000 " ,
92
97
}
93
98
```
0 commit comments