Search code examples
javalogginglog4jlog4j2

Multiple JVMS writing to the same log file in Log4j2 version 2.3


We are upgrading a legacy application to use log4j2. Because the application server (Weblogic 10.3.6.0) doesn't support servlet 3.0 we are at a cap of servlet 2.5 and can go as high as version Log4j version 2.3.

We have 4 JVMs running on the application server. We have 1 log4j2 config per server, so all 4 JVMs use the same config. We can seperate out the log files by appending the JVM name.

We were wondering if it's possible we can remove the JVM name, and have all JVMs write to the same logger? We are not able to use the async logger, and think there may be synchronous file locking issues.

Can anyone confirm if we can combine the log outputs of all 4 JVMS to 1 file, or it is better to separate them out per JVM.

Thank you


Solution

  • If you want to have multiple JVMs write to the same file you must use file locking (locking="true" on the File Appender). However, file locking is not supported on the RollingFileAppender as it cannot be done safely. File locking will also impact the performance of writing to the log files.