AppenderSkeleton.DoAppend中的Log4Net死锁

时间:2019-02-15 16:53:16

标签: log4net

我在多线程服务中使用log4net。而且在某个时间点,服务意外停止响应。我检查了该过程的转储,下面是堆栈。

这是附加程序配置:

        var roller = new RollingFileAppender();
        roller.LockingModel = new MinimalLock();
        roller.File = @"logs\Log_Tabsters_" + appName + "_";
        roller.DatePattern = "yyyy-MM-dd'.log'";
        roller.StaticLogFileName = false;
        roller.AppendToFile = true;
        roller.RollingStyle = RollingMode.Composite;
        roller.Layout = patternLayout;
        roller.MaxSizeRollBackups = 10;
        roller.MaximumFileSize = "1GB";
        roller.ActivateOptions();


            var buffer = new BufferingForwardingAppender();
            buffer.BufferSize = 100;
            buffer.Lossy = false;
            buffer.AddAppender(roller);
            buffer.ActivateOptions();
            hierarchy.Root.AddAppender(buffer);

            var console = new ColoredConsoleAppender();

            var mappingError = new LevelColors();
            mappingError.Level = Level.Error;
            mappingError.ForeColor = Colors.White;
            mappingError.BackColor = Colors.Red;                
            console.AddMapping(mappingError);

            var mappingWarn = new LevelColors();
            mappingWarn.Level = Level.Warn;
            mappingWarn.ForeColor = Colors.White;
            mappingWarn.BackColor = Colors.Yellow;
            console.AddMapping(mappingWarn);

            console.Layout = patternLayout;
            console.ActivateOptions();
            hierarchy.Root.AddAppender(console);

我看到线程卡在了DoAppend中

堆栈跟踪为

                        log4net.dll!log4net.Appender.AppenderSkeleton.DoAppend(log4net.Core.LoggingEvent loggingEvent)
                        log4net.dll!log4net.Util.AppenderAttachedImpl.AppendLoopOnAppenders(log4net.Core.LoggingEvent loggingEvent)
                        log4net.dll!log4net.Repository.Hierarchy.Logger.CallAppenders(log4net.Core.LoggingEvent loggingEvent)
                        log4net.dll!log4net.Repository.Hierarchy.Logger.ForcedLog(System.Type callerStackBoundaryDeclaringType, log4net.Core.Level level, object message, System.Exception exception)
                        log4net.dll!log4net.Repository.Hierarchy.Logger.Log(System.Type callerStackBoundaryDeclaringType, log4net.Core.Level level, object message, System.Exception exception)
                        log4net.dll!log4net.Core.LogImpl.Warn(object message)
                        TabstersCore.dll!Tabsters.Logger.AddLog(string module, string log, Tabsters.LogType logType) Line 129

0 个答案:

没有答案