
I am trying to create custom layout in Logback, using the link, http://stackoverflow.com/questions/14168684/creating-a-custom-layout-in-logb... and i am successful in creating log file. The problem is when I apply "pattern" tag in encoder tag of logback.xml like this, Logback.xml ========== <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? LoggingConsoleLayout.xml - My Cuatom Layout ===================================== public class LoggingConsoleLayout extends LayoutBase<ILoggingEvent>{ @Override public String doLayout(ILoggingEvent event) { StringBuffer sbuf = null; try { sbuf = new StringBuffer(128); sbuf.append("-- "); sbuf.append("["); sbuf.append(event.getLevel()); sbuf.append("]"); sbuf.append(event.getLoggerName()); sbuf.append(" - "); *sbuf.append(encodeData(event.getFormattedMessage()));* *//here i am encoding my log messages and which is important for me* sbuf.append(CoreConstants.LINE_SEPARATOR); } catch(Exception e) { e.printStackTrace(); } return sbuf.toString(); } } when I tried this, <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> <layout class="com.dces.util.LoggingConsoleLayout" > <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern> </layout> </encoder> I got *ERROR in ch.qos.logback.core.joran.spi.Interpreter@17:17 - no applicable action for [Pattern], current ElementPath is [[configuration][appender][encoder][layout][Pattern]]* And my pattern is not applied to my layout... Is there is any possibility to have both layout and pattern tags in encoder tag?