Log4Net消息日志

时间:2012-03-06 00:25:22

标签: c# logging log4net messages log4net-configuration

我正在尝试将log4net用于我的网络服务。我面临的问题是,当我尝试同时发送多条消息时,它只会为第一条消息创建日志。

当我们一次只发送一条消息并等到消息到达侦听器时,日志工作正常。但是当我们同时拍摄多条消息时(不等待听众的响应),它只记录我发送的第一条消息。

这是我的配置。任何人都可以让我知道我错过了什么:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
    </configSections>

    <log4net>
        <root>
            <level value="ALL" />
            <appender-ref ref="ArchiveRollingFileAppender" />
            <appender-ref ref="LogRollingFileAppender" />

        </root>

        <appender name="LogRollingFileAppender" type="log4net.Appender.RollingFileAppender">
            <filter type="log4net.Filter.PropertyFilter">
                <key value="Source" />
                <stringToMatch value="Log" />
            </filter>
            <threshold value="OFF"/>
            <!--<lockingModel type="dndn.ebl.framework.logging.FileLock" />-->
            <filter type="log4net.Filter.DenyAllFilter" />
            <file type="log4net.Util.PatternString">
                <conversionPattern value="{LogFileName}"/>
            </file>
            <appendToFile value="true" />
            <rollingStyle value="Size" />
            <maxSizeRollBackups value="10" />
            <maximumFileSize value="1MB" />
            <staticLogFileName value="true" />
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%date{yyyy-MM-dd HH:mm:ss} [%thread] %-5level [%property{method}] - %message%newline" />
            </layout>
        </appender>
        <appender name="ArchiveRollingFileAppender" type="log4net.Appender.RollingFileAppender">
            <filter type="log4net.Filter.PropertyFilter">
                <key value="Source" />
                <stringToMatch value="Archive" />
            </filter>
            <threshold value="OFF"/>
            <!--<lockingModel type="dndn.ebl.framework.logging.FileLock" />-->
            <filter type="log4net.Filter.DenyAllFilter" />
            <file type="log4net.Util.PatternString">
                <conversionPattern value="{ArchiveFileName}"/>
            </file>
            <appendToFile value="true" />
            <rollingStyle value="Size" />
            <maxSizeRollBackups value="10" />
            <maximumFileSize value="1MB" />
            <staticLogFileName value="true" />
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%message%newline" />
            </layout>
        </appender>
    </log4net>
</configuration>

1 个答案:

答案 0 :(得分:1)

您是否尝试将锁定模型设置为

<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />