[logback-user] Logback Rolling policy issue.

Chandraprakash chandraprakash.kalwar at gmail.com
Wed Mar 12 18:51:30 CET 2014


Dear Troy,

Thanks a lot to help with the appender configurations. I applied the similar
configurations and it is working for me now :-)

Now I am trying to get all the 'info' and 'error' level logs in one
file(infoLogAppender) and all the 'error' level logs in a sepaate
log(errorLogAppender) as well. I tried it using 'LevelFilter' and using
'logger' as well, but it did not work. My configurations looks like:

    <property name="logging.log_dir" value="C:/Logs"/>     
    <property name="logging.log_archive_dir" value="C:/Logs/Archive"/>
    <property name="infoLogName" value="someInfoLog"/>
    <property name="errorLogName" value="someErrorLog"/>
    <property name="consoleLogName" value="consoleLog"/>
    
    
 <appender name="infoLogAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
    <append>true</append>
    <file>${logging.log_dir}/${infoLogName}.log</file>
    <rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
      <maxHistory>10</maxHistory>
     
<fileNamePattern>${logging.log_archive_dir}/${infoLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
      <timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
        <maxFileSize>10KB</maxFileSize>
      </timeBasedFileNamingAndTriggeringPolicy>
    </rollingPolicy>
    <encoder>

        <pattern>%-30(%d{HH:mm:ss.SSS} [%thread]) %-5level %-20.50logger{35}
- %msg%n</pattern>

        <immediateFlush>false</immediateFlush>
    </encoder>    
  </appender>
  
 <appender name="errorLogAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
    <append>true</append>
    <file>${logging.log_dir}/${errorLogName}.log</file>
    <rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
      <maxHistory>10</maxHistory>
     
<fileNamePattern>${logging.log_archive_dir}/${errorLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
      <timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
        <maxFileSize>1MB</maxFileSize>
      </timeBasedFileNamingAndTriggeringPolicy>
    </rollingPolicy>
    <encoder>

        <pattern>%-30(%d{HH:mm:ss.SSS} [%thread]) %-5level %-20.50logger{35}
- %msg%n</pattern>

        <immediateFlush>true</immediateFlush>
    </encoder>    
  </appender>
  
 <appender name="consoleAppender"
class="ch.qos.logback.core.ConsoleAppender">
    <append>true</append>
    <file>${logging.log_dir}/${consoleLogName}.log</file>
    <rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
      <maxHistory>10</maxHistory>
     
<fileNamePattern>${logging.log_archive_dir}/${consoleLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
      <timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
        <maxFileSize>1MB</maxFileSize>
      </timeBasedFileNamingAndTriggeringPolicy>
    </rollingPolicy>
    <encoder>

        <pattern>%-30(%d{HH:mm:ss.SSS} [%thread]) %-5level %-20.50logger{35}
- %msg%n</pattern>

        <immediateFlush>true</immediateFlush>
    </encoder>   
  </appender>

    <root level="TRACE" additivity="true">
        <appender-ref ref="infoLogAppender" />
        <appender-ref ref="errorLogAppender" />
        <appender-ref ref="consoleAppender" />
    </root>


I get some logs on console as well(mainly JPA related). I want them in a
separate log file(consoleAppender). It is also not working.

Could you help here as well? Might be with some example?

Regards,
Chandra



--
View this message in context: http://logback.10977.n7.nabble.com/Logback-Rolling-policy-issue-tp13350p13383.html
Sent from the Users mailing list archive at Nabble.com.


More information about the Logback-user mailing list