diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2020-03-24 13:21:18 -0600 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2020-03-24 13:21:18 -0600 |
commit | 2acb208e325c16a0f73a81957f9094198e97809c (patch) | |
tree | 7fa6a1ff5adf87f5b5a12f15e7a74536e8b933ee /modules | |
parent | e02117cb8a2b0b6dbd3dbb1de4d1569ff63ca617 (diff) |
caddyhttp: Specify default access log for a server (fix #3185)
Diffstat (limited to 'modules')
-rw-r--r-- | modules/caddyhttp/server.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/caddyhttp/server.go b/modules/caddyhttp/server.go index 461865c..c7780b0 100644 --- a/modules/caddyhttp/server.go +++ b/modules/caddyhttp/server.go @@ -172,7 +172,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { logger := accLog if s.Logs != nil && s.Logs.LoggerNames != nil { - logger = logger.Named(s.Logs.LoggerNames[r.Host]) + if loggerName, ok := s.Logs.LoggerNames[r.Host]; ok { + logger = logger.Named(loggerName) + } else { + // see if there's a default log name to attach to + logger = logger.Named(s.Logs.LoggerNames[""]) + } } log := logger.Info |