gpt4 book ai didi

c# - 我正在使用 log4net 进行日志记录,但它没有写入日志

转载 作者:太空宇宙 更新时间:2023-11-03 12:49:48 31 4
gpt4 key购买 nike

我已经对我的 Web.Config 进行了更改

我正在使用.net 4.0

我正在使用 log4net 我已经添加了引用

<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>

<log4net debug="true">
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\Users\n.gupta\Desktop\CacheService.log"/>
<appenToFile value="true" />
<rollingStyle value="Size"/>
<maxsixeRollBackups value="10"/>
<maximumFileSize value="10Mb"/>
<staticLogFileName value="true"/>
<layout type="log4net.PatternLayout">
<conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M - %m%n"/>
</layout>
</appender>
<root>
<level value="DEBUG"/>
<appender-ref ref="RollingLogFileAppender" />
</root>
</log4net>

我已经对 AssemblyInfo.cs 进行了更改

[assembly:log4net.Config.XmlConfigurator(ConfigFile="Web.config",Watch=true)]

我已将调试添加到我的 Controller 中

我有一个装运 Controller ,其中包含我正在记录的创建方法

public class ShipmentController : BaseController
{
private static readonly ILog logger = ogManager.GetLogger(typeof(ShipmentController));
public ActionResult ShipmentCreation()
{
//I have attached the debug code for the message
logger.Debug("Hello I am in Shipment creation Method");
}
}

正在创建文件,但未附加任何内容

最佳答案

您的配置的 XML 中至少有两个语法错误:

<appenToFile value="true" />
<rollingStyle value="Size"/>
<maxsixeRollBackups value="10"/>

appendToFilemaxSize... 至少必须更正。

关于c# - 我正在使用 log4net 进行日志记录,但它没有写入日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36012157/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com