How to configure a custom access.log format in AEM

Avatar

Avatar
Give Back 5
Level 2
MeasurableBusinessResults
Level 2

Likes

0 likes

Total Posts

24 posts

Correct reply

1 solution
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 1
Validate 1
View profile

Avatar
Give Back 5
Level 2
MeasurableBusinessResults
Level 2

Likes

0 likes

Total Posts

24 posts

Correct reply

1 solution
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 1
Validate 1
View profile
MeasurableBusinessResults
Level 2

06-05-2019

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).

Replies

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,462 likes

Total Posts

3,328 posts

Correct reply

949 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,462 likes

Total Posts

3,328 posts

Correct reply

949 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

06-05-2019

Avatar

Avatar
Give Back 5
Level 2
MeasurableBusinessResults
Level 2

Likes

0 likes

Total Posts

24 posts

Correct reply

1 solution
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 1
Validate 1
View profile

Avatar
Give Back 5
Level 2
MeasurableBusinessResults
Level 2

Likes

0 likes

Total Posts

24 posts

Correct reply

1 solution
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 1
Validate 1
View profile
MeasurableBusinessResults
Level 2

06-05-2019

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)

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,410 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,410 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

06-05-2019

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