Solved

Log4j problem. not able to create backup for multiple jvm

Posted on 2004-04-25
1
621 Views
Last Modified: 2007-12-19
Not sure this is the right folder, but please help me.

This is my log4j configuration file.

log4j.logger.test=debug, app1

log4j.appender.consolestdout=org.apache.log4j.ConsoleAppender
log4j.appender.consolestdout.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
log4j.appender.consolestdout.layout.ConversionPattern=%d{dd/MM/yy,HH:mm:ss} %5p [%t] - %m%n

# Configure the file appender :  app1
log4j.appender.app1=org.apache.log4j.RollingFileAppender
log4j.appender.app1.File=d:/test/logs/test.log
log4j.appender.app1.MaxFileSize=1MB
# Keep 4 backup file
log4j.appender.app1.MaxBackupIndex=4
log4j.appender.app1.layout=org.apache.log4j.PatternLayout
log4j.appender.app1.layout.ConversionPattern=%d{dd/MM/yy,HH:mm:ss} %5p [%t] - %m%n

The observation is :
If I only run one Java application that creates this log file, then everything is fine. It is able to create backup file like test.log1 and test.log2 after it reaches file size 1MB.

The problem is :
If I have multiple Java applications (multiple JVM) that use this log file (this file appender) then I found it is not able to create backup file. It always stays at test.log after it reaches 1MB file size. The previous content will be just cleared and then create a new same file.

It might make sense but is there a way to over come this? This is to say I want to make it no difference from 1 JVM or multiple JVM for the log file behavior.

Thank you very much.
0
Comment
Question by:i_am_diablo2000
1 Comment
 
LVL 1

Accepted Solution

by:
KartikShah earned 50 total points
ID: 10918704
I do not know much. But one thing that I know about Log4J is that it takesa exclusive lock on the log file to which it appends, i.e. it does not allow any other program to delete the file, even empty the contents.

This might be the source of your problem, if this is te culprit, in that case it will be difficult that we can do an thing much about it. :(
0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
password protect pdf 11 76
reflections, dynamic class loading 3 70
maven webservice example issue 2 134
equalIsNot  challenge 43 142
When you’re making plans to join the modern business race, you should analyze various details that may affect your results. Nowadays, millions of businesses are trying to grow into established and appreciated professional enterprises.
This tutorial shows how to create a greeting card by combining two image layers and a text layer on a PC using a free image editing app.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question