MinimalLock partially solves the problem (as @Mark mentioned), but if you're using RollingFileAppender, you'll run into other problems. When the file rolls, you may find yourself in a race condition where one process overwrites another process's newly created log file.
Other options include RemoteLogger, where you have a simple server set up to receive and record logging events sent by other processes. Likewise, you can log to a SQL database. I wrote a simple appended that logs to Redis; you'd need a simple application to read from Redis and record to a file. The problem with these approaches is they all introduce a point of failure. When something isn't working right is often when you need logs the most, and then they might not be available.
So my solution was to avoid the problem altogether by having each process log to its own file. This was easy to do with a change in configuration. In your (Rolling)FileAppender
configuration, use:
<file type="log4net.Util.PatternString" value="c:mylog-[%processid].txt" />
The process ID becomes part of the file name. Yes, this means you now have several log files to comb through, but a log file aggregator like Graylog, Splunk, or Logscape can help.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…