I am trying to create custom layout in Logback, using the link,


Creating a custom layout in Logback


and i am successful in creating log file.


The problem is when I apply "pattern" tag in encoder tag of logback.xml like this,



<appender name="appLogFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>C:/tmp.log</fileNamePattern>
</rollingPolicy>

**<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<pattern> %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n </pattern>
<layout class="com.dces.util.LoggingConsoleLayout" />
</encoder>
</appender>**


it is not applied on log file, which is created, and I am getting content without date&time AS BELOW.


-- [ERROR]main.java.com.srccodes.log.LogbackHello - Welcome to the HelloWorld example of Logback. -- [ERROR]main.java.com.srccodes.log.LogbackHello - Dummy error message.


Actually if I remove class="ch.qos.logback.core.encoder.LayoutWrappingEncoder" in encoder tag ,pattern is working, but then my custom layout is not working.


I want to apply pattern tag as well as custom layout tag on encoder tag.Is it is possible?


Can anyone help me in this?


No comments:

Post a Comment