在我的类库中,我使用 Log4net 来获取日志。日志文件已创建,但其中没有记录任何日志。帮助获取日志......在我的 App.Config 和 ClassLibrary 下面给出。它只是在 C: 驱动器中创建一个文本文件作为“TestLog1.txt”。但是里面没有记录日志...
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,
log4net" />
</configSections>
<log4net debug="true">
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\\TestLog1.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="5" />
<maximumFileSize value="5MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{absolute} , [%thread] , %level , %logger , %method , %l , %message %n" />
</layout>
</appender>
<root>
<level value="INFO"/>
<appender-ref ref="RollingFileAppender" />
</root>
<appSettings>
<!-- <add key="log4net.Internal.Debug" value="true" />-->
</appSettings>
</log4net>
</configuration>
类库.cs
using log4net;
using log4net.Config;
[assembly: log4net.Config.XmlConfigurator(Watch=true)]
namespace SampleClassLibrary
{
public class DbServices
{
private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public DataSet Get_Login(string User,string Pwd)
{
log.Info("Entering Get_Login method");
}