-
-
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
- Loading branch information
1 parent
4d6370b
commit 10cf134
Showing
5 changed files
with
178 additions
and
10 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
148 changes: 148 additions & 0 deletions
148
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,148 @@ | ||
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 { | ||
vars access_logger_names "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