There seems to be some discussion on whether log4net is thread-safe, the consensus is that the framework is thread-safe, but appenders are not and need to be used correctly to a
Straight from the log4net FAQ:
Is log4net thread-safe?
Yes, log4net is thread-safe.
So, no need for manual locking.
But I've had a deadlock with ColoredConsoleAppender. And it sources comment states that internal writer (m_consoleOutputWriter) is not thread safe!
/// <summary>
/// The console output stream writer to write to
/// </summary>
/// <remarks>
/// <para>
/// This writer is not thread safe.
/// </para>
/// </remarks>
private System.IO.StreamWriter m_consoleOutputWriter = null;
And I've switched back to basic ConsoleAppender and have no issues since then.
According to this link, RollingFileAppender is thread safe (as far as logging is concerned). This is coming from one of the developers of log4net. He specifically says that locking like this is not required in your code:
lock(logger)
{
logger.Info("Hello!");
}