Try XmlConfigurator.Configure();
That's what I do. I think there are some limitations to it, though. I don't think you will be able to watch the file, as it's actually loaded by the framework instead of by log4net, and the framework doesn't watch the file. I don't need this, so it always works fine for me.
-- Two antennae met on a roof, fell in love and got married. The ceremony was nice, but the reception was fantastic. On Tue, 12 Jul 2005, Wang, Jason @ Newport MacArthur wrote:
If I want to use the default configuration file (eg, MyApplication.exe.config), do I need to call ConfigureAndWatch? -----Original Message----- From: Ron Grabowski Sent: Tuesday, July 12, 2005 5:30 PM To: Log4NET User Subject: RE: Windows Service You need to call Configure at some point or else log4net won't configure itself. I usually call ConfigureAndWatch(FileInfo) then write a message indicating my application has started: log.Info("Application Started") --- "Wang, Jason @ Newport MacArthur" <[EMAIL PROTECTED]> wrote:All, Currently, I started calling log.Debug("...") with just, private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(EmailServiceStarter)); Should I switch to manually load the configuration file? Such as, log4net.Config.DOMConfigurator.ConfigureAndWatch(new System.IO.FileInfo("c:\\EmailService\\EmailService.exe.config")); ? As you can tell from my previous post, the .config file is not exclusive to log4net so I don't understand why my main app can read the .config file, but log4net can't. Thanks, Jason -----Original Message----- From: Ron Grabowski [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 12, 2005 5:24 PM To: Log4NET User Subject: RE: Windows Service What does your call to Configure look like? --- "Wang, Jason @ Newport MacArthur" <[EMAIL PROTECTED]> wrote:I'm stuck. I can't figure out what would cause the "No appenders could be found for logger" error. Is it possible that log4net isn't reading the config file corrently? Thanks, Jason _____ From: Wang, Jason @ Newport MacArthur Sent: Tuesday, July 12, 2005 2:50 PM To: 'Log4NET User' Subject: RE: Windows Service All, Per Erik's suggestion I turned on debugging and downloaded sysinternal's DebugView and found the following 2 entries: [2136] log4net: DefaultRepositorySelector: defaultRepositoryType [log4net.Repository.Hierarchy.Hierarchy] [2136] log4net: DefaultRepositorySelector: creating repository for assembly [EmailService, Version=1.0.0.0, Culture=neutral,PublicKeyToken=null][2136] log4net: DefaultRepositorySelector: assembly [EmailService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null] using domain [log4net-default-domain] and repository type [log4net.Repository.Hierarchy.Hierarchy] [2136] log4net: DefaultRepositorySelector: creating repository for domain [log4net-default-domain] using type [log4net.Repository.Hierarchy.Hierarchy] [2136] log4net:ERROR Logger: No appenders could be found for logger [Company.Project.EmailService.EmailServiceStarter] [2136] log4net:ERROR Logger: Please initialize the log4net system properly. Below is my EmailService.exe.config. What am I missing? Thanks, Jason <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/></configSections> <appSettings> <add key="runinterval" value="60000" /> </appSettings> <log4net debug="true"> <!-- Define some output appenders --> <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="c:\EmailSerivceLog.txt" /> <appendToFile value="true" /> <maxSizeRollBackups value="5" /> <maximumFileSize value="100" /> <rollingStyle value="Size" /> <staticLogFileName value="true" /> <layout type="log4net.Layout.PatternLayout"> <header value="[Header]" /><footer value="[Footer]" /><conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" /> </layout> </appender> <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" > <applicationName value="APT - Email Service" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /> </layout> </appender> <!-- Setup the root category, add the appenders and set the default level --> <root> <level value="DEBUG" /> <appender-ref ref="EventLogAppender" /> <appender-ref ref="RollingLogFileAppender" /> </root> </log4net> </configuration> _____ From: Sargent, Erik [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 12, 2005 1:55 PM To: Log4NET User Subject: RE: Windows Service=== message truncated ===
