Log4net随机停止记录

时间:2014-07-30 08:25:47

标签: c# .net log4net log4net-appender

我在服务的事件日志中收到以下消息:

Exception: System.NullReferenceException

Message: Object reference not set to an instance of an object.

StackTrace:
   at log4net.Appender.RollingFileAppender.AdjustFileBeforeAppend() in C:\Projects\Framework\log4net-1.2.11\src\Appender\RollingFileAppender.cs:line 609
   at log4net.Appender.RollingFileAppender.Append(LoggingEvent loggingEvent) in C:\Projects\Framework\log4net-1.2.11\src\Appender\RollingFileAppender.cs:line 562
   at LSports.Common.Logger.Appenders.AsynchronousFileAppender.LogMessages() in d:\tfsV3\Dev\Common\Logger\LSports.Common.Logger\Appenders\AsynchronousFileAppender .cs:line 63
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

我在webservice旁边的系统中的更多项目中使用log4net,它也随机卡在那里。

我查看了log4net的源文件,其中发生了异常,它在尝试执行文件滚动时发生

    if (m_rollSize) 
        {
            /* this line*/ if ((File != null) && ((CountingQuietTextWriter)QuietWriter).Count >= m_maxFileSize) 
            {
                RollOverSize();
            }
        }

可能导致这种情况的原因是什么?它只是完全随机发生

1 个答案:

答案 0 :(得分:0)

经过大量搜索后我终于找到了问题,log4net实际挂起,因为它试图将错误打印到控制台,我的应用程序被隐藏,因此无法打印到控制台,只是停止调用log4net的线程。