-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
logging: Add support for additional logger filters other than hostname (
#6082) Co-authored-by: Francis Lavoie <[email protected]>
- Loading branch information
1 parent
4af38e5
commit 4356635
Showing
6 changed files
with
216 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 151 additions & 0 deletions
151
caddytest/integration/caddyfile_adapt/log_filter_with_header.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
localhost { | ||
log { | ||
output file ./caddy.access.log | ||
} | ||
log health_check_log { | ||
output file ./caddy.access.health.log | ||
no_hostname | ||
} | ||
log general_log { | ||
output file ./caddy.access.general.log | ||
no_hostname | ||
} | ||
@healthCheck `header_regexp('User-Agent', '^some-regexp$') || path('/healthz*')` | ||
handle @healthCheck { | ||
log_name health_check_log general_log | ||
respond "Healthy" | ||
} | ||
|
||
handle { | ||
respond "Hello World" | ||
} | ||
} | ||
---------- | ||
{ | ||
"logging": { | ||
"logs": { | ||
"default": { | ||
"exclude": [ | ||
"http.log.access.general_log", | ||
"http.log.access.health_check_log", | ||
"http.log.access.log0" | ||
] | ||
}, | ||
"general_log": { | ||
"writer": { | ||
"filename": "./caddy.access.general.log", | ||
"output": "file" | ||
}, | ||
"include": [ | ||
"http.log.access.general_log" | ||
] | ||
}, | ||
"health_check_log": { | ||
"writer": { | ||
"filename": "./caddy.access.health.log", | ||
"output": "file" | ||
}, | ||
"include": [ | ||
"http.log.access.health_check_log" | ||
] | ||
}, | ||
"log0": { | ||
"writer": { | ||
"filename": "./caddy.access.log", | ||
"output": "file" | ||
}, | ||
"include": [ | ||
"http.log.access.log0" | ||
] | ||
} | ||
} | ||
}, | ||
"apps": { | ||
"http": { | ||
"servers": { | ||
"srv0": { | ||
"listen": [ | ||
":443" | ||
], | ||
"routes": [ | ||
{ | ||
"match": [ | ||
{ | ||
"host": [ | ||
"localhost" | ||
] | ||
} | ||
], | ||
"handle": [ | ||
{ | ||
"handler": "subroute", | ||
"routes": [ | ||
{ | ||
"group": "group2", | ||
"handle": [ | ||
{ | ||
"handler": "subroute", | ||
"routes": [ | ||
{ | ||
"handle": [ | ||
{ | ||
"access_logger_names": [ | ||
"health_check_log", | ||
"general_log" | ||
], | ||
"handler": "vars" | ||
}, | ||
{ | ||
"body": "Healthy", | ||
"handler": "static_response" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"match": [ | ||
{ | ||
"expression": { | ||
"expr": "header_regexp('User-Agent', '^some-regexp$') || path('/healthz*')", | ||
"name": "healthCheck" | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"group": "group2", | ||
"handle": [ | ||
{ | ||
"handler": "subroute", | ||
"routes": [ | ||
{ | ||
"handle": [ | ||
{ | ||
"body": "Hello World", | ||
"handler": "static_response" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"terminal": true | ||
} | ||
], | ||
"logs": { | ||
"logger_names": { | ||
"localhost": [ | ||
"log0" | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters