java - Logback rolling file appender - can I zip many logs into one file? -
my current logback config looks this:
<appender name="rolling" class="ch.qos.logback.core.rolling.rollingfileappender"> <file>${log.dir}/${log.package}.log</file> <encoder> <pattern>${log.pattern}</pattern> </encoder> <rollingpolicy class="ch.qos.logback.core.rolling.timebasedrollingpolicy"> <filenamepattern>${log.dir}/${log.package}.%d{yyyy-mm-dd}.%i.log.zip</filenamepattern> <timebasedfilenamingandtriggeringpolicy class="ch.qos.logback.core.rolling.sizeandtimebasedfnatp"> <!-- or whenever file size reaches 1mb. --> <maxfilesize>1mb</maxfilesize> </timebasedfilenamingandtriggeringpolicy> <!-- keep no more 3 months data. --> <maxhistory>90</maxhistory> <cleanhistoryonstart>true</cleanhistoryonstart> </rollingpolicy> </appender>
this works fine irritatingly creates multiple zip file ...1.zip
...2.zip
etc.
is there way can specify zip file name ${log.dir}/${log.package}.%d{yyyy-mm-dd}.log.zip
name of files in zip file ${log.dir}/${log.package}.%i.log
? i.e. make 1 zip file per day each time file reaches 1mb zip ....1.log
, ...2.log
etc.
yes can add multiple files zip file using rollingfileappender fixedwindowrollingpolicy.
<appender name="errorlogs" class="ch.qos.logback.core.rolling.rollingfileappender"> <target>system.err</target> <file>${log_location}{error_filename}</file> <rollingpolicy class="ch.qos.logback.core.rolling.fixedwindowrollingpolicy"> <filenamepattern>${log_location}{err_zip}</filenamepattern> <minindex>1</minindex> <maxindex>3</maxindex> </rollingpolicy> <triggeringpolicy class="ch.qos.logback.core.rolling.sizebasedtriggeringpolicy"> <maxfilesize>${maxfilesize}</maxfilesize> </triggeringpolicy> <encoder> <pattern>${default_pattern}</pattern> </encoder> </appender>
since cannot use both timebased rolling , sizebased rolling suggestion set high value maxfilesize neither of these constraint can minimalised
Comments
Post a Comment