以下は私の設定とトレースからの出力です、それはロガーを設定せず、それを使用するとログに何も書き込まれません(おそらくすべてのログレベルが有効になっていないため)。何が問題なのですか?
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<appSettings>
<add key="log4net.Internal.Debug" value="true" />
</appSettings>
<log4net>
<!-- Define some output appenders -->
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="logs\rolling-log.txt" />
<appendToFile value="true" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="100" />
<rollingStyle value="Size" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<header value="[Header]
" />
<footer value="[Footer]
" />
<conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
</layout>
</appender>
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<file value="logs\bidz-log.txt" />
<!-- Example using environment variables in params -->
<!-- <file value="${TMP}\log-file.txt" /> -->
<sppendToFile value="true" />
<!-- An alternate output encoding can be specified -->
<!-- <encoding value="unicodeFFFE" /> -->
<layout type="log4net.Layout.PatternLayout">
<geader value="[Header]
" />
<footer value="[Footer]
" />
<conversionPattern value="%date [%thread] %-5level %logger [%ndc] <%property{auth}> - %message%newline" />
</layout>
<!-- Alternate layout using XML
<layout type="log4net.Layout.XMLLayout" /> -->
</appender>
<!-- Setup the root category, add the appenders and set the default level -->
<!-- Specify the level for some specific categories -->
<root>
<level value="ALL" />
<appender-ref ref="RollingLogFileAppender" />
</root>
<debug value="true" />
<logger name="Presence">
<level value="ALL" />
<appender-ref ref="RollingLogFileAppender" />
</logger>
</log4net>
---デバッグ
log4net: log4net Assembly [log4net, Version=1.2.11.0, Culture=neutral, PublicKeyToken=null]. Loaded from [C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\presenceapproval\4fbf2110\7bd5e802\Assembly\dl3\8d349422\73aaf263_e5adcc01\log4net.DLL]. (.NET Runtime [2.0.50727.3615] on Microsoft Windows NT 5.1.2600 Service Pack 3)
log4net: defaultRepositoryType [log4net.Repository.Hierarchy.Hierarchy]
log4net: Creating repository for Assembly [App_Web_zceiak6m, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]
log4net: Assembly [App_Web_zceiak6m, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null] Loaded From [C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\presenceapproval\4fbf2110\7bd5e802\App_Web_zceiak6m.dll]
log4net: Assembly [App_Web_zceiak6m, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null] does not have a RepositoryAttribute specified.
log4net: Assembly [App_Web_zceiak6m, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null] using repository [log4net-default-repository] and repository type [log4net.Repository.Hierarchy.Hierarchy]
log4net: Creating repository [log4net-default-repository] using type [log4net.Repository.Hierarchy.Hierarchy]
さて、私がする必要があるのは、実際に最初にconfigureメソッドの1つを呼び出すことでした。例:log4net.Config.XmlConfigurator.Configure();
とにかく、構成を別のファイルに移動し、web.config
に以下を追加しました。
<appSettings>
<add key="log4net.Config" value="log4net.config"/>
<add key="log4net.Config.Watch" value="True"/>
</appSettings>`