Hi Dave,

Thanks for the suggestion.
I will change the code accordingly and let you know the outcome.

Regards,
Mayuran

On Sun, May 17, 2015 at 11:44 PM, David Roussel <nabble@diroussel.xsmail.com> wrote:
Mayuran,

You can add FINALIZE_SESSION_MARKER to the MDC to trigger the sub-appender to be cleaned up.  This is documented in http://logback.qos.ch/manual/appenders.html

Once you do that the sub-appender goes into lingering state for 10 seconds, then the appender will be closed after that.

Dave

On 17 May 2015, at 10:50, mayuran satchithanantham <mayuran19@gmail.com> wrote:

Hi David, 

Thanks for the prompt reply.
If you remember the way to trigger the closing of appender, please let me know.

Regards,
Mayuran

On Sun, May 17, 2015 at 5:46 PM, David Roussel <nabble@diroussel.xsmail.com> wrote:
Hi Mayuran,

The logic controlling this is in ch.qos.logback.core.sift.AppenderTracker I seem to remember I’ve had problems with this in the past, but I don’t remember the details now.  It’s controlled by a timeout.  Maybe there should be an explicit way to trigger the closing of an appender controlled by the sifting logic.

David

On 17 May 2015, at 09:44, mayuran satchithanantham <mayuran19@gmail.com> wrote:

Hi logback geeks,

We are using logback "SiftingAppender" for generating the log files based on the date and other information such as cycle(Each date can have multiple cycles).

Following are the sample logging file names

20150515_1_Job1.log
20150515_2_Job1.log

For the above scenario we are using the 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 is the java code for logging the details to the 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 some other jobs that do the housekeeping of the old log files with the retention of 2 days(Two day old files will be moved to another location).

But even after the job completes, we are not able to move the file. We suspect that logback is holding the resource and not letting the file to move or delete.

All the jobs are deployed in a single war file in apache tomcat 8 server.

Can anyone suggest how to enforce logback to release the resource after logging is completed?

Regards,
Mayuran
_______________________________________________
Logback-user mailing list
Logback-user@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user


_______________________________________________
Logback-user mailing list
Logback-user@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user

_______________________________________________
Logback-user mailing list
Logback-user@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user


_______________________________________________
Logback-user mailing list
Logback-user@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user