<div dir="ltr"><div>Below is an example of some configuration that I use to do the same thing. I hate that there is a requirement in my organization to do this however, it's the wrong way about it if you ask me. For my money, I think you need to strive for log centralization and this represents an effort to decentralize logs. There are a set of tools that I'd recommend using for log centralization. Namely, Logstash backed by Elasticsearch and Kibana. I'd urge you to look at how these tools can help you.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><?xml version="1.0" encoding="UTF-8"?><br>
<configuration debug="true"><br>  <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"><br>    <resetJUL>true</resetJUL><br>  </contextListener><br>  <property name="contextName" value="someapp" /><br>
  <contextName>${contextName}</contextName><br>  <jmxConfigurator /><br>  <appender name="default" class="ch.qos.logback.core.rolling.RollingFileAppender"><br>    <append>true</append><br>
    <file>${logging.log_dir}/${contextName}.log</file><br>    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><br>      <cleanHistoryOnStart>true</cleanHistoryOnStart><br>
      <maxHistory>${logging.appender_max_file_history:-1}</maxHistory><br>      <fileNamePattern>${logging.log_archive_dir}/${contextName}.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern><br>      <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><br>
        <maxFileSize>${logging.appender_max_file_size}</maxFileSize><br>      </timeBasedFileNamingAndTriggeringPolicy><br>    </rollingPolicy><br>    <encoder class="${logging.encoder.default}" /><br>
  </appender><br>  <appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender"><br>    <append>true</append><br>    <filter class="ch.qos.logback.classic.filter.LevelFilter"><br>
      <level>ERROR</level><br>      <onMatch>ACCEPT</onMatch><br>      <onMismatch>DENY</onMismatch><br>    </filter><br>    <file>${logging.log_dir}/${contextName}-errors.log</file><br>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><br>      <cleanHistoryOnStart>true</cleanHistoryOnStart><br>      <maxHistory>${logging.appender_max_file_history:-1}</maxHistory><br>
      <fileNamePattern>${logging.log_archive_dir}/${contextName}-errors.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern><br>      <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><br>
        <maxFileSize>${logging.appender_max_file_size}</maxFileSize><br>      </timeBasedFileNamingAndTriggeringPolicy><br>    </rollingPolicy><br>    <encoder class="${logging.encoder.default}" /><br>
  </appender><br>  <root level="${logging.level.default}"><br>    <appender-ref ref="default"/><br>    <appender-ref ref="error"/><br>  </root><br></configuration></blockquote>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Mar 12, 2014 at 11:51 AM, Chandraprakash <span dir="ltr"><<a href="mailto:chandraprakash.kalwar@gmail.com" target="_blank">chandraprakash.kalwar@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear Troy,<br>
<br>
Thanks a lot to help with the appender configurations. I applied the similar<br>
configurations and it is working for me now :-)<br>
<br>
Now I am trying to get all the 'info' and 'error' level logs in one<br>
file(infoLogAppender) and all the 'error' level logs in a sepaate<br>
log(errorLogAppender) as well. I tried it using 'LevelFilter' and using<br>
'logger' as well, but it did not work. My configurations looks like:<br>
<br>
    <property name="logging.log_dir" value="C:/Logs"/><br>
    <property name="logging.log_archive_dir" value="C:/Logs/Archive"/><br>
<div class="">    <property name="infoLogName" value="someInfoLog"/><br>
    <property name="errorLogName" value="someErrorLog"/><br>
</div>    <property name="consoleLogName" value="consoleLog"/><br>
<br>
<br>
 <appender name="infoLogAppender"<br>
<div class="">class="ch.qos.logback.core.rolling.RollingFileAppender"><br>
    <append>true</append><br>
</div>    <file>${logging.log_dir}/${infoLogName}.log</file><br>
    <rollingPolicy<br>
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><br>
      <maxHistory>10</maxHistory><br>
<br>
<fileNamePattern>${logging.log_archive_dir}/${infoLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern><br>
      <timeBasedFileNamingAndTriggeringPolicy<br>
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><br>
        <maxFileSize>10KB</maxFileSize><br>
      </timeBasedFileNamingAndTriggeringPolicy><br>
    </rollingPolicy><br>
<div class="">    <encoder><br>
<br>
        <pattern>%-30(%d{HH:mm:ss.SSS} [%thread]) %-5level %-20.50logger{35}<br>
- %msg%n</pattern><br>
<br>
</div>        <immediateFlush>false</immediateFlush><br>
    </encoder><br>
  </appender><br>
<br>
 <appender name="errorLogAppender"<br>
<div class="">class="ch.qos.logback.core.rolling.RollingFileAppender"><br>
    <append>true</append><br>
</div>    <file>${logging.log_dir}/${errorLogName}.log</file><br>
    <rollingPolicy<br>
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><br>
      <maxHistory>10</maxHistory><br>
<br>
<fileNamePattern>${logging.log_archive_dir}/${errorLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern><br>
      <timeBasedFileNamingAndTriggeringPolicy<br>
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><br>
<div class="">        <maxFileSize>1MB</maxFileSize><br>
      </timeBasedFileNamingAndTriggeringPolicy><br>
    </rollingPolicy><br>
    <encoder><br>
<br>
</div><div class="">        <pattern>%-30(%d{HH:mm:ss.SSS} [%thread]) %-5level %-20.50logger{35}<br>
- %msg%n</pattern><br>
<br>
        <immediateFlush>true</immediateFlush><br>
</div>    </encoder><br>
  </appender><br>
<br>
 <appender name="consoleAppender"<br>
class="ch.qos.logback.core.ConsoleAppender"><br>
    <append>true</append><br>
    <file>${logging.log_dir}/${consoleLogName}.log</file><br>
    <rollingPolicy<br>
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><br>
      <maxHistory>10</maxHistory><br>
<br>
<fileNamePattern>${logging.log_archive_dir}/${consoleLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern><br>
      <timeBasedFileNamingAndTriggeringPolicy<br>
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><br>
<div class="">        <maxFileSize>1MB</maxFileSize><br>
      </timeBasedFileNamingAndTriggeringPolicy><br>
    </rollingPolicy><br>
    <encoder><br>
<br>
</div><div class="">        <pattern>%-30(%d{HH:mm:ss.SSS} [%thread]) %-5level %-20.50logger{35}<br>
- %msg%n</pattern><br>
<br>
        <immediateFlush>true</immediateFlush><br>
</div><div class="">    </encoder><br>
  </appender><br>
<br>
    <root level="TRACE" additivity="true"><br>
</div>        <appender-ref ref="infoLogAppender" /><br>
        <appender-ref ref="errorLogAppender" /><br>
        <appender-ref ref="consoleAppender" /><br>
    </root><br>
<br>
<br>
I get some logs on console as well(mainly JPA related). I want them in a<br>
separate log file(consoleAppender). It is also not working.<br>
<br>
Could you help here as well? Might be with some example?<br>
<br>
Regards,<br>
Chandra<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://logback.10977.n7.nabble.com/Logback-Rolling-policy-issue-tp13350p13383.html" target="_blank">http://logback.10977.n7.nabble.com/Logback-Rolling-policy-issue-tp13350p13383.html</a><br>

<div class="HOEnZb"><div class="h5">Sent from the Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Logback-user mailing list<br>
<a href="mailto:Logback-user@qos.ch">Logback-user@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/logback-user" target="_blank">http://mailman.qos.ch/mailman/listinfo/logback-user</a><br>
</div></div></blockquote></div><br></div>