views:

430

answers:

2

I have a number of identical processes that are writing to a single log file using a Log4j DailyRollingFileAppender. I am concerned that multiple processes may try and roll the file and that chaos will ensue. Does the implementation allow for this using with some kind of locking mechanism? - the Javadoc doesn't mention it.

+1  A: 

it is not advisible to let multiple processes access the same log file. mayhem will occur

Salandur
+1  A: 

There is a solution in this Question.

Louis Haußknecht
Thanks - I did check for dupes but didn't find that one.
teabot
If you implement the writer, versus just using log4j again, you can add an extra feature. The receiver can queue the writes. If the queue becomes too large, you can dump data. This can be a great performance feature should your environment become IO bound (can happen with a lot of logging). It also allows you to move the logging component to another machine, which cuts down the vast amount of performance impact of logging.
Jim Rush