0
我有一個控制檯應用程序,我試圖用log4net設置日誌記錄。 我已經做了所有的基本步驟設置它 - 在應用 爲什麼log4net沒有記錄消息
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<appSettings>
<add key="LogFileRootFolderPath" value="C:\TestApplicationLogs\"/>
</appSettings>
<log4net>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="TestApplication.log" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<maxSizeRollBackups value="14" />
<maximumFileSize value="15000KB" />
<datePattern value="yyyyMMdd" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="{%level}%date{MM/dd HH:mm:ss} - %message%newline"/>
</layout>
</appender>
<root>
<level value="All" />
<!-- You can use levels, in increasing order of verbosity: Off, Fatal, Error, Warn, Info, Debug, All -->
<appender-ref ref="RollingFileAppender" />
</root>
</log4net>
附註:
- 添加的配置在AssemblyInfo.cs中\
新增
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
在Program.cs的
private static readonly log4net.ILog log = log4net.LogManager.GetLogger (System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); static void Main(string[] args) { log.Info("App Started"); }
任何人都可以請導遊什麼:我在C創建一個新文件夾 'TestApplicationLogs'不見了?
對不起,我的錯誤,我在錯誤的地方尋找日誌文件:( – iniki