4 Replies Latest reply on Sep 16, 2018 11:55 AM by Jörg Hoh

    AEM 6.3 Customize log message using appender and slf4j

    mohanj30558408 Level 1

      In our AEM 6.3 project, we have a need to add the additional attribute in log message. Basically, we want to customize the message format. So we have created one logback file under src/main/resources/logback.xml. Content of the logfile is as follows

      <configuration>  <appender name="SampleProject.log" class="ch.qos.logback.core.FileAppender"> <file>SampleProject.log</file> \<append>true</append> <encoder> <pattern>%d %-5level %X{sling.userId:-NA} [%thread] %logger{30} %marker- %msg %n</pattern> <immediateFlush>true</immediateFlush> </encoder> </appender>  <logger name="org.wc.project" level="INFO"/>  </configuration>

      And under Apache Sling Logging Configuration, we have created one log configuration as follows with "same name" as appender name.

      org.apache.sling.commons.log.file="SampleProject.log" org.apache.sling.commons.log.level="info" org.apache.sling.commons.log.logger.paatern ="org.wc.project" org.apache.sling.commons.log.pattern="{0,date,dd.MM.yyyy HH:mm:ss.SSS} *{4}* [{2}] {3} {5}" 

      But the customized message format is now shown in SampleProject.log. Can anybody please provide any pointers for the same.