网页配置
<configuration>
<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="C:\\Users\\Vini\\Websites\\Campaigns2\\Campaign2\\LogFile.log"/>
<rollingStyle value="Date"/>
<datePattern value="yyyyMMdd"/>
<appendToFile value="true"/>
<maxSizeRollBackups value="5" />
<maximumFileSize value="5MB" />
<countDirection value="1"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%level %logger %date{ISO8601} - %message%newline"/>
</layout>
<root>
<!-- Options are "ALL", "DEBUG", "INFO", "WARN", "ERROR", "FATAL" and "OFF". -->
<level value="ALL"/>
<appender-ref ref="RollingFile"/>
</root>
</appender>
</log4net>
默认.aspx
private static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(Education_Default));
protected void Page_Load(object sender, EventArgs e)
{
logger.Info("Default Page Campaign 1");
if (!IsPostBack)
{
}
}
全球.asax
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
log4net.Config.XmlConfigurator.Configure();
}
没有得到任何错误。它只是不写入文件
编辑:我只想在每个页面加载时写入日志文件
请有人帮助