Apache Meecrowave: enable access log
If you are using or tested Apache Meecrowave you can wonder why you don't see access log by default, this is because, to let you use the logging you want it is not on out of the box.
Thanks to the pluggable and unified configuration system of Apache Meecrowave you can set the configuration in multiple location but one common option is meecrowave.properties but another one, if you are using Meecrowave CLI (based on commons-cli) is to just enable it in the CLI arguments.
There is in Meecrowave Configuration an option to enable the access log using the Meecrowave logging system - Log4j2 by default but it can move to JUL if desired excluding log4j2 from dependencies. This option is named tomcat-access-log-pattern and takes Tomcat AccessLog pattern as value. It can be common or combined if you want to reused the standard ones or a custom one as '%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"' for example.
If you are using Kubernetes and Meecrowave CLI in your image, you can enable it in the args of your container:
spec:
containers:
- name: myapp
image: myapp:latest
args: ["--tomcat-access-log-pattern", "common"]
If you prefer to hardcode the default you can put it in meecrowave.properties in your classpath:
tomcat-access-log-pattern = %h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"
Or you can just set it on the Configuration class, either directly if you launch yourself Meecrowave or through a Meecrowave.ConfigurationCustomizer if you want to configure the instance programmatically.
With this setting, the access log lines will go to the org.apache.meecrowave.tomcat.LoggingAccessLogPattern logger so you can tune the output using your logging framework (log4j2.xml or logging.properties depending if you are using Log4j2 or JUL). The common tuning is to only keep the message and EOL instead of logging the logger name and date since it is redundant but with the cloud and Kubernetes/Loki/... erea it is not really required anymore so just ensure it works with your stack :).
From the same author:
In the same category: