HTTP 访问日志记录
可以为 HTTP 端点配置访问日志设置。
HTTP 访问日志设置
HTTP 访问日志包含由 HTTP 端点所处理的所有入站客户机请求的记录。可以在 HTTP 服务器中启用访问日志记录,或者使用下列两种方式在 Liberty 服务器中将其启用:多个端点共用一个日志,或者每个端点一个日志。
- 使用公共日志
要对多个使用公共设置的端点启用日志记录,请包括 httpAccessLogging 作为 server.xml 文件中的一个顶级元素,然后从多个 httpEndpoint 元素引用该元素:
<httpAccessLogging id="accessLogging"/> <httpEndpoint id="defaultHttpEndpoint" accessLoggingRef="accessLogging"/> <httpEndpoint id="otherHttpEndpoint" accessLoggingRef="accessLogging" httpPort="9081" httpsPort="9444"/>
- 对每个端点使用不同的日志
要对每个端点启用日志记录,请使用 accessLogging 子元素并指定一个与其他日志不冲突的文件路径:
<httpEndpoint id="defaultHttpEndpoint"> <accessLogging filepath="${server.output.dir}/logs/http_defaultEndpoint_access.log"/> </httpEndpoint>
- 使用 HTTP 服务器的日志
要获取可用的 HTTP 服务器端属性及其描述的列表,请参阅 Apache 模块 mod_log_config。
HTTP 访问日志格式
要获取可用的日志格式属性及其描述的列表,请参阅 HTTP 传输通道定制属性中的 WebSphere® Application Server 的 accessLogFormat 配置。此日志格式字符串是在 server.xml 文件中使用 httpAcccessLogging 或 accessLogging 元素的 logFormat 属性指定的:
<httpAccessLogging logFormat='%h %u %{t}W "%r" %s %b'/>
或
<httpEndpoint id="defaultHttpEndpoint">
<accessLogging filepath="${server.output.dir}/logs/http_defaultEndpoint_access.log"
logFormat='%h %i %u %t "%r" %s %b' />
</httpEndpoint>