我用我的ASP.NET MVC3項目log4net的,但所有的日誌記錄屬性,如IsDebugEnabled
==假爲什麼我所有的log4net級別都是假的?
在我的AssemblyInfo我:
[assembly: XmlConfigurator(Watch = true)]
在我的日誌類我有
Web.Config中public Log4NetLogger()
{
log4net.Config.XmlConfigurator.Configure();
Logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
}
我的相關配置的東西是:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false"/>
</sectionGroup>
</configSections>
<log4net debug="false">
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="100" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<connectionString value="{removed}" />
<commandText value="INSERT INTO Logging ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)" />
<parameter>
<parameterName value="@log_date" />
<dbType value="DateTime" />
<layout type="log4net.Layout.RawTimeStampLayout" />
</parameter>
<parameter>
<parameterName value="@thread" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%thread" />
</layout>
</parameter>
<parameter>
<parameterName value="@log_level" />
<dbType value="String" />
<size value="50" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%level" />
</layout>
</parameter>
<parameter>
<parameterName value="@logger" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%logger" />
</layout>
</parameter>
<parameter>
<parameterName value="@message" />
<dbType value="String" />
<size value="4000" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message" />
</layout>
</parameter>
<parameter>
<parameterName value="@exception" />
<dbType value="String" />
<size value="2000" />
<layout type="log4net.Layout.ExceptionLayout" />
</parameter>
</appender>
<!--Possible levels:-->
<!--DEBUG-->
<!--INFO-->
<!--WARN-->
<!--ERROR-->
<!--FATAL-->
<root>
<level value="All" />
<appender-ref ref="AdoNetAppender" />
</root>
</log4net>
</applicationSettings>
</configuration>
我已經很沮喪,只是想要做
public Log4NetLogger()
{
Logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
Logger.IsDebugEnabled = true;
}
點不過當然Logger.IsDebugEnabled
沒有任何setter方法:/
我有什麼做的就是這個該死的東西的工作?
如果您對此問題進行了排序,您是否可以批准以下答案之一? – 2017-10-16 08:33:31