java - logback SiftingAppender generated log files cannot be deleted untill stop the tomcat server -


we using logback "siftingappender" generating log files based on date , other information such cycle(each date can have multiple cycles).

following sample logging file names

20150515_1_job1.log
20150515_2_job1.log

for above scenario using following logback configuration.

<appender name="batch_logger_appender" class="ch.qos.logback.classic.sift.siftingappender">     <discriminator>         <key>batchloggerfilename</key>         <defaultvalue>unknown</defaultvalue>     </discriminator>     <sift>         <appender class="ch.qos.logback.core.fileappender">             <file>${batchlog.dir}/${batchloggerfilename}.log</file>             <layout class="ch.qos.logback.classic.patternlayout">                 <pattern>%d{yyyy-mm-dd_hh:mm:ss.sss} | %-5level | [%thread] | %msg%n%rex</pattern>             </layout>         </appender>     </sift> </appender>  <logger name="batch_logger" level="info" additivity="false">     <appender-ref ref="batch_logger_appender"></appender-ref> </logger> 

following java code logging details specific logs files.

private static final logger batch_logger = loggerfactory         .getlogger("batch_logger");  public void info(jobinfo jobinfo, string message) {     mdc.put("batchloggerfilename", jobinfo.getjobid());     batch_logger.info(message);     mdc.remove("batchloggerfilename"); } 

we have other jobs housekeeping of old log files retention of 2 days(two day old files moved location).

but after job completes, not able move file. suspect logback holding resource , not letting file move or delete.

all jobs deployed in single war file in apache tomcat 8 server.

can suggest how enforce logback release resource after logging completed?

regards,
mayuran

the following suggestion suggested logback support in there support group when asked question.

mayuran,

you can add finalize_session_marker mdc trigger sub-appender cleaned up. documented in http://logback.qos.ch/manual/appenders.html

once sub-appender goes lingering state 10 seconds, appender closed after that.

dave


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -