簡體   English   中英

Log4net隨機停止記錄

[英]Log4net randomly stops logging

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

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()

我在系統中除Web服務之外的更多項目中使用了log4net,它也被隨機卡在了那里。

我查看了發生異常的log4net的源文件,它在嘗試執行文件滾動時發生

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

是什么原因造成的? 它只是隨機發生

經過大量搜索后,我終於找到了問題,由於試圖向控制台打印錯誤,log4net實際上掛起,並且我的應用程序被隱藏,因此無法打印到控制台,只是停止了稱為log4net的線程。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM