Forget for a second the question of why on earth would you do such a thing - if, for whatever reason, two FileAppenders are configured with the same file - will this setup work?
相关问题
- convert logback.xml to log4j.properties
- logging static methods in a parent class
- Wrap log4j or create custom logger?
- ClassNotFoundException found in Log4j 2.0
- Undeploying a Grails App from Glassfish gets a Cla
相关文章
- Can IntelliJ create hyperlinks to the source code
- how can I disable output to log4j.rootLogger?
- Log4j2 using {} against using %d or %s
- How do I redirect a javaw.exe console output to a
- log4j: Standard way to prevent repetitive log mess
- Log4j2 not working in WebLogic 12.2.1
- Grails and Log4J : How to logs in different files
- Managing a Large Number of Log Files Distributed O
Log4j's FileAppender does not allow for two JVM's writing to the same file. If you try, you'll get a corrupt log file. However, logback, log4j's successor, in prudent mode allows two appenders even in different JVMs to write to the same file.
From Log4j FAQ a3.3
How do I get multiple process to log to the same file?
As to what that actually means I will be investigating myself.
I also found the following workaround on another SO question:
Code + Example
It doesn't directly answer your question, but log4*net*'s FileAppender has a LockingModel attribute that you can set to only lock when the file is actually in use. So if you had two FileAppenders working in the same thread with MinimalLock set, it would probably work perfectly fine. On different threads, you might hit deadlock once in a while.
A cursory web search didn't turn up any useful results about implementing MinimalLock in log4j.