Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

How to configure a custom access.log format in AEM


Level 2

I currently have the standard LogManager configuration that writes an access.log file for AEM.

The value of Message Pattern (org.apache.sling.commons.log.pattern) is "{5}". This logs the standard NCSA extended/combined log format.

Now I want to add custom fields, as described in:

Apache Sling :: Client Request Logging

However, I cannot add these format strings in the system console LogManager configuration like that. If I try it just stops working.

As I understand it, the "{5}" is just a placeholder for the default message being logged by the logger (which in this case is NCSA).

My org.apache.sling.engine.impl.log.RequestLogger is configured to an SLF4J logger.

The way I understand the section about MDC in Apache Sling :: Logging it sounds like it should be possible to pass through some custom log message format strings to the logger.

Now I tried

%d{dd.MM.yyyy HH:mm:ss.SSS} *%p* %h %l %u %t "%r" %>s %b "%\{Referer}i" "%\{User-Agent}i" "%\{Host}i"

But this does not work, logging stops in the access log when I try this.

Can someone point out the proper way to enter the access log format string in the Message Pattern field in the system console?

And no, I don't want to write my own logger in code - I prefer to just configure it and move on debugging (so please do not point out links to documentation of how to write my own custom loggers, I'm aware of those).

4 Replies

I have seen that link but it requires coding. As stated, I am looking for an option to simply configure it with the out of the box logger.

I just want to be able to modify the log format of the access log in the system console (e.g. like log format in Apache)

Most of the custom logging requires you to map log to Java packages defined in code.


Level 2

Did you find a workaround for this?