When I tried your app.config I received an exception immediately upon
calling XmlConfigurator.Configure();
I had to move some things around in it for it to work:
There doesn't seem to be an exception when I call Environment.Exit(1);
either.
Does modifying your app.config like below solve your problem?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
</sectionGroup>
</configSections>
<applicationSettings>
<!-- .... -->
</applicationSettings>
<log4net>
<!-- Define some output appenders -->
<appender name="LogFileAppender"
type="log4net.Appender.FileAppender">
<file value="GenericInterfaceClient.log" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level
%logger - %message%newline" />
</layout>
</appender>
<logger name="default">
<level value="ALL" />
<appender-ref ref="LogFileAppender" />
</logger>
</log4net>
</configuration>
On Thu, Jul 16, 2009 at 1:42 PM, Dahl, Scott (CMA Consulting) <[email protected]
> wrote:
> I have a .net application using log4net that works fine up until the
> application exits using Environment.Exit(). At that point I get the
> following error message:
>
> “log4net:ERROR XmlConfigurator: Failed to find configuration section
> 'log4net' in the application's .config file. Check your .config file for the
> <log4net> and <configSections> elements. The configuration section should
> look like: <section name="log4net"
>
> type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />”
>
>
>
> The log file is created and entries are written fine when the app runs.
> I’ve tried doing a logmanager.shudown() prior to the Environment.Exit() but
> that doesn’t seem to help either. The issue is more of an annoyance than
> anything else as the logging works as expected. The app is running at a
> client site though and they want to know why they’re seeing this error in
> their scheduler.
>
>
>
> Here’s the log4net entries in my app.config.
>
>
>
> <?xml version="1.0" encoding="utf-8"?>
>
> <configuration>
>
> <configSections>
>
> <sectionGroup name="applicationSettings"
> type="System.Configuration.ApplicationSettingsGroup,
> System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
> >
>
> <section name="log4net" type="
> log4net.Config.Log4NetConfigurationSectionHandler" />
>
> </sectionGroup>
>
> </configSections>
>
>
>
> <!-- This section contains the log4net configuration settings -->
>
> <log4net>
>
> <!-- Define some output appenders -->
>
> <appender name="LogFileAppender" type="log4net.Appender.FileAppender
> ">
>
> <file value=".\\GenericInterfaceClient.log" />
>
> <appendToFile value="true" />
>
> <layout type="log4net.Layout.PatternLayout">
>
> <conversionPattern value="%date [%thread] %-5level %logger -
> %message%newline" />
>
> </layout>
>
> </appender>
>
> <logger name="default">
>
> <level value="ALL" />
>
> <appender-ref ref="LogFileAppender" />
>
> </logger>
>
> </log4net>
>
> </applicationSettings>
>
> </configuration>
>
>
>
> Any ideas?
>
>
>