我已使用 %X 模式成功在应用程序日志中记录线程上下文值。现在,我想在 tomcat 访问日志 tomcat 中记录相同的值。有什么模式可以记录吗?
最佳答案
恐怕您无法在访问日志中记录线程上下文。
以下是可用选项:
%a - Remote IP address
%A - Local IP address
%b - Bytes sent, excluding HTTP headers, or '-' if zero
%B - Bytes sent, excluding HTTP headers
%h - Remote host name (or IP address if enableLookups for the connector is false)
%H - Request protocol
%l - Remote logical username from identd (always returns '-')
%m - Request method (GET, POST, etc.)
%p - Local port on which this request was received. See also %{xxx}p below.
%q - Query string (prepended with a '?' if it exists)
%r - First line of the request (method and request URI)
%s - HTTP status code of the response
%S - User session ID
%t - Date and time, in Common Log Format
%u - Remote user that was authenticated (if any), else '-'
%U - Requested URL path
%v - Local server name
%D - Time taken to process the request, in millis
%T - Time taken to process the request, in seconds
%F - Time taken to commit the response, in millis
%I - Current request thread name (can compare later with stacktraces)
据我所知,您唯一能做的就是记录当前线程名称(%I
),然后在应用程序日志中查找它以获取其上下文信息。
关于java - 如何在 tomcat 访问日志中记录线程上下文值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32863538/