What I am trying to do: I want to add a AccessLogValve to the tomcat server.xml so that I can log custom header values. (ref: https://jfrog.com/knowledge-base/how-can-i-log-custom-request-headers-using-the-tomcat-access-log-valve/)
Problem I am having:
Every-time the gradle is run it creates new server.xml. I want to add a cargo.tomcat.valve
container property however I cannot find a format that works.
The valve I want to add is the Access Log Valve
https://tomcat.apache.org/tomcat-8.5-doc/config/valve.html#Access_Log_Valve
A failed example is containerProperties ['cargo.tomcat.valve'] = 'className=org.apache.catalina.valves.AccessLogValve| pattern=combined'
I have tried various versions of the above but none seem to work.
I can see that the maven example is
<cargo.tomcat.valve.stuckthread>
className=org.apache.catalina.valves.StuckThreadDetectionValve|
threshold=60
</cargo.tomcat.valve.stuckthread>
However I cannot find a way to add custom valves using gradle.
After the study, we figured out that the access log updates in server.xml file for tomcat can work with the cargo plugin version >= 2.3 (the current latest one is 2.7.1 as of 30-Apr-2020)
The example for updating the valve in build.gradle should be as below:
containerProperties = [
'cargo.tomcat.ajp.port' : 8050,
'cargo.tomcat.valve' : "className=org.apache.catalina.valves.AccessLogValve|pattern=%h %l %u %t "%r" %s %b %{X-Custom-Header}i|directory=logs|prefix=localhost_access_log.|suffix=.txt"
]