Main roller: FixedWindowRollingPolicy; trigger: TimeBasedRollingPolicy

Hey friends! Greetings from Chile. I'd like to achieve the following: 1. I want my main rollingPolicy to be FixedWindowRollingPolicy. This way, my main logging file will always be named the same way and backup files will by rolling. 2. I want the triggeringPolicy to be TimeBasedRollingPolicy, so it rolls every day at 04:00 AM. I couldn't find a way to achieve this and I only saw examples of SizeBasedTriggeringPolicy, which is not my desired triggeringPolicy. I couldn't find a parameter for TimeBasedRollingPolicy and besides of that it seems to require fileNamePattern. Is there any way to achieve this? Thanks in advance! Best regards. -- Felipe

<appender name="default" class="ch.qos.logback.core.rolling.RollingFileAppender"> <append>true</append> <file>${logging.log_dir}/${contextName}.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${logging.log_archive_dir}/${contextName}.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <maxFileSize>${logging.appender_max_file_size}</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> </rollingPolicy> <encoder class="${logging.encoder.default}" /> </appender> The configuration above uses runtime properties (property name wrapped in ${}) so you can just fill in the values with whatever you can imagine. This configuration rolls the file every night at mid-night (you'd need to look at the documentation of SizeAndTimeBasedFNATP to see how to do it at 4am rather than mid-night--I think it's possible). The nice thing about this policy is that not only rolls on a time schedule (as dictated by the date stamp format), but it also rolls when the file gets too large (maxFileSize). Hope this helps! Troy On Wed, Dec 11, 2013 at 7:32 AM, Felipe <felipenaranja@gmail.com> wrote:
Hey friends! Greetings from Chile.
I'd like to achieve the following:
I want my main rollingPolicy to be FixedWindowRollingPolicy. This way, my main logging file will always be named the same way and backup files will by rolling. I want the triggeringPolicy to be TimeBasedRollingPolicy, so it rolls every day at 04:00 AM. I couldn't find a way to achieve this and I only saw examples of SizeBasedTriggeringPolicy, which is not my desired triggeringPolicy. I couldn't find a parameter for TimeBasedRollingPolicy and besides of that it seems to require fileNamePattern.
Is there any way to achieve this? Thanks in advance!
Best regards.
-- Felipe
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
participants (2)
-
Felipe
-
Troy Hart