2
我有一個控制檯應用程序使用log4net(通過Castle Windsor)。當我調試時,一切都很好地記錄到控制檯,但是當我發佈並運行應用程序時,沒有任何記錄。log4net控制檯應用程序未登錄發佈
我有我的log4net配置在一個單獨的文件(log4net.config)。 我在想這不是找到配置文件,但這只是一個猜測。
我是一個web開發人員,並沒有部署許多控制檯應用程序。我錯過了什麼嗎? 我需要手動將log4net.config文件複製到exe目錄嗎?
我在VS2010。
的app.config:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor"/>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false"/>
</configSections>
<appSettings>
...
<add key="log4net.Internal.Debug" value="false"/>
</appSettings>
<startup>
<supportedRuntime version="v2.0.50727"/></startup>
<castle>
<components>
...
</components>
<facilities>
<facility id="loggingfacility" configfile="log4net.config" loggingapi="log4net" type="Castle.Facilities.Logging.LoggingFacility, Castle.Facilities.Logging"/>
</facilities>
</castle>
</configuration>
log4net.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<log4net>
<root>
<!-- Value of priority may be ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF -->
<priority value="ALL" />
<appender-ref ref="ConsoleAppender" />
</root>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d: [%-5p] %m%n" />
</layout>
</appender>
<logger name="Castle">
<level value="INFO" />
</logger>
</log4net>
</configuration>
我確實嘗試過,但仍然沒有快樂。我剛剛測試了一個正常的console.writeline,這個工作,所以我認爲這絕對是log4net的配置問題。 我不知道我是否設置了錯誤的級別。但它是全部。我的直覺是,它甚至沒有找到配置文件... – autonomatt 2010-08-31 12:26:04
我是否需要將App.config設置爲「內容」和「始終複製」? – autonomatt 2010-08-31 12:28:52
我再次嘗試了你的建議veljkoz ...並且這次它工作:) – autonomatt 2010-08-31 12:39:23