0
我無法讓log4net記錄ASP.Net webforms中的任何內容。這是林做:在Visual Basic中使用log4net和ASP.Net WebForms
的Web.config
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net"/>
</configSections>
<log4net>
<appender name="MyLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\inetpub\MySite\Logs\MyLog.log"/>
<param name="AppendToFile" value="true"/>
<rollingStyle value="Size"/>
<maxSizeRollBackups value="10"/>
<maximumFileSize value="10KB"/>
<staticLogFileName value="true"/>
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%-5p%d{yyyy-MM-dd hh:mm:ss} – %m%n"/>
</layout>
</appender>
<logger name="MyLogger">
<level value="ALL"/>
<appender-ref ref="MyLogFileAppender"/>
</logger>
</log4net>
...
的Global.asax
<%@ Application Language="VB" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="log4net" %>
<script runat="server">
Public Shared Logger As ILog
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Config.XmlConfigurator.ConfigureAndWatch(New FileInfo("Web.config"))
End Sub
Test.aspx的
Protected Sub cmdTest_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdTest.Click
Dim logger As log4net.ILog = log4net.LogManager.GetLogger("MyLogger")
logger.Debug("A test debug message")
End Sub
我已經給'C:\ inetpub \ MySite \ Logs'文件夾提供'每個人'的訪問權限,並且仍然沒有出現日誌。任何想法我可能做錯了什麼?