In Log4j2 appenders it's useful to use the contextPath as the filename, as in:
filename="/logs/${web:contextPath}.log
. This means one log configuration can be reused across multiple webapps.
However If a contextPath is /foo/bar
this creates the file /logs/foo/bar.log
. Is there anyway to replace the /
in the contextPath with _
so the filename is /logs/foo_bar.log
?
For me this is more useful than replicating the context path structure directly into the logs. I 've read up on the StringSubstitution docs and can't see anyway to do it, but if anyone has a solution it would be really helpful!