c# - Castle Log4Net facility not logging -
I am trying to use the Castle Lodge 4 Net feature in window service. I could not find it to write a log, so I thought I would make a console app to try it first. I'm still not seeing the log file look. What have I done wrong or happy?
Namespace Castle Lodgeing FacilityWithLog 4 Net {Class Program {Private Stable IWindsorContainer_container; Static zero main (string [] args) {_container = new windsor CONTAINER (); _container.Register (Component.For & lt; IService & gt; () ImplementedBy. () LifestyleTransient ()); _ Container.Adffiliiti & lt; LoggingFilitiation & gt; (F => F. Logging (Logar Implementation. 4 Net);); // _ container.Install (FromAssembly.This ()); Var service = _container.Resolve & lt; IService & gt; (); Service.TestLogging (); }} Public Interface IService {void TestLogging (); } Public Service: IService {Private ILogger Logger = NullLogger.Instance; Public Zero Testlogging () {Logger.Info ("This is an exam"); } Public Illogger Logger {Receive Return Logar; } Set {logger = value; }}}} Adding my log4net config to log4net.config is as follows ...
& lt; Configuration & gt; & Lt; ConfigSections & gt; & Lt; Section name = "log4net" type = "log4net.config.loginNetConfigurationSectionHandler, log4net" /> & Lt; / ConfigSections & gt; & Lt; Log4net & gt; & Lt; Appender name = "rolling file" type = "log4net.Appender.RollingFileAppender" & gt; & Lt; File value = "logging \ log.txt" /> & Lt; AppendToFile value = "true" /> & Lt; DatePattern value = "dd-MM-yyyy'.log '" /> & Lt; StaticLogFileName value = "wrong" /> & Lt; Rolling style value = "date" /> & Lt; Max file value value = "10MB" /> & Lt; MaxSizeRollBackups value = "5" /> & Lt; DateTimeStrategy type = "log4net.Appender.RollingFileAppender + UniversalDateTime" /> & Lt; Layout type = "log4net.Layout.PatternLayout" & gt; & Lt; Conversion value = "% utcdate% -5level% logger -% message% newline% exception" /> & Lt; / Layout & gt; & Lt; / Appender & gt; & Lt; Root & gt; & Lt; Level value = "DEBUG" /> & Lt; Appender-Rif Referee = "Rolling File" /> & Lt; / Root & gt; & Lt; / Log4net & gt; & Lt; / Configuration & gt;
There was nothing wrong with my code or configuration The problem was that log4net config Was not set to copy to the output directory! Neither shame nor log-4 net were able to tell me that the logfile could not be found.
Comments
Post a Comment