Hi,
I created my own Logger from 'Apache Sling Logging Logger' configuration :
[img]Capture01.JPG[/img]
But the 'Message pattern' field is not picked up.
Instead, the 'Message pattern' from 'Apache Sling Logging' configuration is used.
[img]Capture02.JPG[/img]
How can I 'force' the Log system to use my message pattern, and not the default one ?
Solved! Go to Solution.
Output is correct as per your config. Probably you are not understanding the log back pattern. Go through [0] to understand better. Let me try to explain & then answer your query. Still did not understand plan to play with logback locally to get familiar.
[0] http://logback.qos.ch/manual/
[1] http://logback.qos.ch/manual/layouts.html
[2] %d{dd.MM.yyyy HH:mm:ss.SSS} *%level* [%thread] %logger %msg%n
[3] %d{dd.MM.yyyy HH:mm:ss.SSS} *%level* %msg%n
Views
Replies
Total Likes
Hello,
thank you for your answers.
I already read these steps, here is what I did.
(I replaced the following <identifier> by 'myproject' name) :
I created, under my configuration folder '/apps/<project-name>/config'
- a node for the new Apache Sling Logging Logger Configuration (named org.apache.sling.commons.log.LogManager.factory.config-<identifier>)
jcr:primaryType="sling:OsgiConfig"
org.apache.sling.commons.log.file="logs/<identifier>.log"
org.apache.sling.commons.log.names="[com.<identifier>.test, com.<identifier>.dev]"
org.apache.sling.commons.log.level="debug"
org.apache.sling.commons.log.pattern="\{0,date,dd.MM.yyyy HH:mm:ss.SSS\} *\{4\}* \{5\}"
- a node for the new Apache Sling Logging Writer Configuration (named org.apache.sling.commons.log.LogManager.factory.writer-<identifier>)
jcr:primaryType="sling:OsgiConfig"
org.apache.sling.commons.log.file="logs/<identifier>.log"
org.apache.sling.commons.log.file.number="5"
org.apache.sling.commons.log.file.size="10mb"
The '/crx-quickstart/logs/<identifier>.log' file is created.
The log level is 'debug', as I specified.
But the pattern does not correspond to the one I defined on the Logger Configuration ("{0,date,dd.MM.yyyy HH:mm:ss.SSS} *{4}* {5}")
The pattern is "{0,date,dd.MM.yyyy HH:mm:ss.SSS} *{4}* [{2}] {3} {5}".
It corresponds to the 'Default' pattern, from 'org.apache.sling.commons.log.LogManager.factory.config'.
My question is : why is my pattern not used ?
Is there a step I did wrong ?
Views
Replies
Total Likes
Here is an extract from the content of the log file :
09.07.2015 18:33:47.854 *INFO* [0:0:0:0:0:0:0:1 [1436459625329] GET /content/testPage.html HTTP/1.1] com.mypackage.MyClass1 myLog1 09.07.2015 18:35:02.541 *INFO* [0:0:0:0:0:0:0:1 [1436459702535] GET /content/testPage.html HTTP/1.1] com.mypackage.MyClass2 myLog2 09.07.2015 18:35:02.686 *DEBUG* [0:0:0:0:0:0:0:1 [1436459702535] GET /content/testPage.html HTTP/1.1] com.mypackage.MyClass3 myLog3 09.07.2015 18:35:02.686 *DEBUG* [0:0:0:0:0:0:0:1 [1436459702535] GET /content/testPage.html HTTP/1.1] com.mypackage.MyClass3 myLog4 09.07.2015 18:35:02.686 *DEBUG* [0:0:0:0:0:0:0:1 [1436459702535] GET /content/testPage.html HTTP/1.1] com.mypackage.MyClass3 myLog5
As you can see, the current pattern is "{0,date,dd.MM.yyyy HH:mm:ss.SSS} *{4}* [{2}] {3} {5}".
I expected the pattern "{0,date,dd.MM.yyyy HH:mm:ss.SSS} *{4}* {5}" as I wrote on my configuration.
I expected logs like this :
09.07.2015 18:33:47.854 *INFO* myLog1 09.07.2015 18:35:02.541 *INFO* myLog2 09.07.2015 18:35:02.686 *DEBUG* myLog3 09.07.2015 18:35:02.686 *DEBUG* myLog4 09.07.2015 18:35:02.686 *DEBUG* myLog5
Views
Replies
Total Likes
Not sure what do you mean by not picked up. Did you look into content of log file? If so what is it logged
Views
Replies
Total Likes
Hello Sham,
I don't understand all your answers/english.
- "Still did not understand plan to play with logback locally to get familiar."
-> Not sure about what you mean here.
You do not understand why I am trying to get this log pattern ?
- "The number in the config you specified [...] is conversion word length"
-> I think this is wrong.
According to this documentation, the number corresponds to an argument, which determines what will be displayed :
http://docs.adobe.com/docs/en/cq/5-6-1/deploying/configure_logging.html
org.apache.sling.commons.log.pattern supports up to six arguments.
{0} The timestamp of type java.util.Date
{1} the log marker
{2} the name of the current thread
{3} the name of the logger
{4} the log level
{5} the log message
- "to do that, create a file such that logger configured to set as [3] and place at crx-quickstart"
-> I do not understand this sentence.
Could you rephrase it please ?
I used to get some logs with the pattern I wanted.
Since AEM 6.0, it seems like I can not get this pattern on my log files.
Is there a change about the way to get log patterns we want ?
Output is correct as per your config. Probably you are not understanding the log back pattern. Go through [0] to understand better. Let me try to explain & then answer your query. Still did not understand plan to play with logback locally to get familiar.
[0] http://logback.qos.ch/manual/
[1] http://logback.qos.ch/manual/layouts.html
[2] %d{dd.MM.yyyy HH:mm:ss.SSS} *%level* [%thread] %logger %msg%n
[3] %d{dd.MM.yyyy HH:mm:ss.SSS} *%level* %msg%n
Views
Replies
Total Likes
paulj91788997 wrote...
My question is : why is my pattern not used ?
Is there a step I did wrong ?
Step is not wrong & it was clear from screenshot of original post. What i asked you to look is content inside the log files.
Views
Replies
Total Likes
I'm also having an issue with this. I am using AEM 6.2 SP1.
In the documentation on "creating a custom log file" the documentation discusses the creation of a sling:OsgiConfig node. If I modify the log pattern inside that node -- no effect. I also tried to modify the log pattern once the logger has been deployed and also tried creating one from scratch (http://localhost:4502/system/console/configMgr) -- but chaning the log pattern has no effect.
Views
Replies
Total Likes
This seems like a product bug. AEM 6.2 picks up the message pattern defined only in the default Logging Configuration. Message Pattern in custom logging configurations are overridden by the default one. You will notice that if you change the message pattern in the default logging configuration, it will get reflected in all the logger files.
nikashbahadur Do you know of any document or another information about this bug? Eg. bug ID, release note etc.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies