Log4net日志文件根本没有创建 [英] Log4net log file is not creating at all
问题描述
我正在使用.net framework 4.0和net framework 4.0的log4net,我正在使用log4net的app.configuration文件,这是我的配置文件。
i am using .net framework 4.0 and the log4net for the net framework 4.0 , i am using the app.configuration file for the log4net here it is my config file.
< configuration>
&NBSP; < configSections>
&NBSP; &NBSP; < section name =" log4net" type =" log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
&NBSP; < / configSections>
< log4net>
&NBSP; < appender Name =" LogFileAppender" type =" log4net.Appender.FileAppender">
&NBSP; &NBSP; < param name =" File"值= QUOT; d:\log-file.txt的" />
&NBSP; &NBSP; < param name =" AppendToFile" value =" true" />
&NBSP; &NBSP; < layout type =" log4net.Layout.PatternLayout">
&NBSP; &NBSP; &NBSP; < param name =" Header" value =" [Header] \\\\ nn" />
&NBSP; &NBSP; &NBSP; < param name ="页脚" value =" [Footer] \\ nn" />
&NBSP; &NBSP; &NBSP; < param name =" ConversionPattern" value ="%d [%t]%-5p%c%m%n" />
&NBSP; &NBSP; < / layout>
&NBSP; < / appender>
&NBSP; < root>
&NBSP; &NBSP; < level value =" ALL" />
&NBSP; &NBSP; < appender-ref ref =" LogFileAppender" />
&NBSP; < / root>
< / log4net>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net>
<appender Name=" LogFileAppender" type="log4net.Appender.FileAppender">
<param name="File" value="D:\log-file.txt" />
<param name="AppendToFile" value="true"/>
<layout type="log4net.Layout.PatternLayout">
<param name="Header" value="[Header]\r\n"/>
<param name="Footer" value="[Footer]\r\n"/>
<param name="ConversionPattern" value="%d [%t] %-5p %c %m%n"/>
</layout>
</appender>
<root>
<level value="ALL"/>
<appender-ref ref="LogFileAppender"/>
</root>
</log4net>
我还放了
i also put the
程序集:log4net.Config.XmlConfigurator(ConfigFile =" app.config",Watch = true)]
assembly: log4net.Config.XmlConfigurator(ConfigFile ="app.config",Watch=true)]
并且还将应用目标框架更改为.net框架4但仍然没有创建日志文件..可以任何人帮助我在哪里做错了?任何形式的帮助都将受到高度赞赏。
and also changed the applicaiton target frame to .net framework 4 but still the log file is not creating ..can anybody help me where i am doing wrong ? any sort of help will be highly appreciated.
推荐答案
尝试替换:
<param name="File" value="D:\log-file.txt" />
with
<param name="File" value="log-file.txt" />
日志文件将在您的调试文件夹中创建。
The log file will be created in your debug folder.
这篇关于Log4net日志文件根本没有创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!