Tomcat Valve Component Audit log date format customisation
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
When enabling the access log via Tomcat's Valve Component, the default log date format is dd/M/yyyy:hh:mm:ss:
1
[29/Sep/2020:15:17:19 +1000] Apache-HttpClient/4.5.6 (Java/1.8.0_151) 127.0.0.1 GET GET /c740/rest/gadgets/1.0/g/messagebundle/und/gadget.common%2Cgadget.activity.stream HTTP/1.1 3910 200 1652 http-nio-6740-exec-1
This can be customised to a different format such as yyyy-MM-dd hh:mm:ss
Environment
Tomcat
Solution
Below is an example of how to do this in server.xml file:
1
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" requestAttributesEnabled="true" prefix="confluence_access_log" suffix=".log" pattern="%{yyyy-MM-dd HH:mm:ss.SSSZ}t %{X-AUSERNAME}o %{User-Agent}i %h %m %r %b %s %D %I" />
Output:
1
2020-09-29 15:26:38.384+1000 - Apache-HttpClient/4.5.6 (Java/1.8.0_151) 127.0.0.1 GET GET /c740/rest/gadgets/1.0/g/messagebundle/und/gadget.common%2Cgadget.activity.stream HTTP/1.1 3910 200 1652 http-nio-6740-exec-10
Was this helpful?