我们如何自定义dropwizard的默认访问日志格式。我想包含一个请求我的访问日志文件的标头。
您可以使用以下配置在访问日志中添加自定义标头
requestLog:
# type: classic <- removing these are imp
# timeZone: IST <- removing these are imp
appenders:
- type: file
currentLogFilename: /usr/share/app/logs/access.log
archivedLogFilenamePattern: /usr/share/app/logs/access-%i.log
archivedFileCount: 2
maxFileSize: 200MB
logFormat: \"%i{x-forwarded-for} %l %u [%t] %r %s %b %i{Referer} %i{User-Agent} %D\"
在上面的示例中,我们记录了 x-forwarded-for、Referer、User-Agent 标头。 访问日志的样本是
10.49.3.116 - - [11/Oct/2023:05:42:56 +0000] POST /v2/url?url_converted=false HTTP/1.1 200 525 - curl/7.52.1 22