mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-26 13:43:47 +03:00
httpcaddyfile: Fix duplicate access log when debug is on (#4746)
This commit is contained in:
parent
0be3d99543
commit
af7321511c
2 changed files with 55 additions and 8 deletions
|
@ -254,20 +254,13 @@ func (st ServerType) Setup(inputServerBlocks []caddyfile.ServerBlock,
|
|||
}
|
||||
customLogs = append(customLogs, ncl)
|
||||
}
|
||||
|
||||
// Apply global log options, when set
|
||||
if options["log"] != nil {
|
||||
for _, logValue := range options["log"].([]ConfigValue) {
|
||||
addCustomLog(logValue.Value.(namedCustomLog))
|
||||
}
|
||||
}
|
||||
// Apply server-specific log options
|
||||
for _, p := range pairings {
|
||||
for _, sb := range p.serverBlocks {
|
||||
for _, clVal := range sb.pile["custom_log"] {
|
||||
addCustomLog(clVal.Value.(namedCustomLog))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !hasDefaultLog {
|
||||
// if the default log was not customized, ensure we
|
||||
|
@ -280,6 +273,15 @@ func (st ServerType) Setup(inputServerBlocks []caddyfile.ServerBlock,
|
|||
}
|
||||
}
|
||||
|
||||
// Apply server-specific log options
|
||||
for _, p := range pairings {
|
||||
for _, sb := range p.serverBlocks {
|
||||
for _, clVal := range sb.pile["custom_log"] {
|
||||
addCustomLog(clVal.Value.(namedCustomLog))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// annnd the top-level config, then we're done!
|
||||
cfg := &caddy.Config{AppsRaw: make(caddy.ModuleMap)}
|
||||
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
debug
|
||||
}
|
||||
|
||||
:8881 {
|
||||
log {
|
||||
format console
|
||||
}
|
||||
}
|
||||
----------
|
||||
{
|
||||
"logging": {
|
||||
"logs": {
|
||||
"default": {
|
||||
"level": "DEBUG",
|
||||
"exclude": [
|
||||
"http.log.access.log0"
|
||||
]
|
||||
},
|
||||
"log0": {
|
||||
"encoder": {
|
||||
"format": "console"
|
||||
},
|
||||
"level": "DEBUG",
|
||||
"include": [
|
||||
"http.log.access.log0"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"apps": {
|
||||
"http": {
|
||||
"servers": {
|
||||
"srv0": {
|
||||
"listen": [
|
||||
":8881"
|
||||
],
|
||||
"logs": {
|
||||
"default_logger_name": "log0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue