log4net 文件附加程序未创建文件
我过去使用过 log4net,没有遇到任何问题,但是在将其记录到文件附加程序时遇到了一些问题。非常简单的例子。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<appender name="DebugFileAppender" type="log4net,Appender.FileAppender">
<file value="Logfile.log" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%5p [%d] - %m%n" />
</layout>
</appender>
<root>
<appender-ref ref="DebugFileAppender" />
</root>
</log4net>
</configuration>
I have used log4net in the past without any trouble, however I am having some issues getting it to log to a file appender. Very simple example.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<appender name="DebugFileAppender" type="log4net,Appender.FileAppender">
<file value="Logfile.log" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%5p [%d] - %m%n" />
</layout>
</appender>
<root>
<appender-ref ref="DebugFileAppender" />
</root>
</log4net>
</configuration>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
执行帐户是否有权写入该文件夹?
Does the executing account have permission to write to the folder?
尝试为 IIS_IUSRS 的日志文件夹设置写入权限
Try set write permission for the log folders for IIS_IUSRS
type 属性中的逗号应替换为句点:
type="log4net.Appender.FileAppender"
您应该会看到类似于以下内容的错误
The comma in the type attribute should be replaced with a period:
type="log4net.Appender.FileAppender"
You should be seeing an error similar to