logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Schall" <mike.sch...@gmail.com>
Subject Re: How to use separate config file for log4net
Date Fri, 05 Dec 2008 18:14:51 GMT
You don't need anything in your app.config.  Just use
the log4net.Config.XmlConfigurator.ConfigureAndWatch method instead as pass
it a file with your log4net definitions.
Log4Net.config:
<log4net>
    ...
    <root>
        ...
    </root>
</log4net>

This will also allow you to change logging settings while the program is
running.

Mike

On Fri, Dec 5, 2008 at 9:46 AM, wijitha <wijithapaw@gmail.com> wrote:

>
> Hi all
>
> I want to use log4net with my project.
> here is the simple example i tried.
>
> App.config :
>
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
>    <configSections>
>       <section name="log4net"
> type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
>
>  </configSections>
>
>  <log4net>
>     A1 is set to be a ConsoleAppender
>    <appender name="A1" type="log4net.Appender.ConsoleAppender">
>
>       A1 uses PatternLayout
>      <layout type="log4net.Layout.PatternLayout">
>        <conversionPattern value="%-4timestamp [%thread] %-5level %logger
> %ndc - %message%newline" />
>      </layout>
>    </appender>
>
>     Set root logger level to DEBUG and its only appender to A1
>    <root>
>      <level value="DEBUG" />
>      <appender-ref ref="A1" />
>    </root>
>  </log4net>
>  </configuration>
>
> here is the code:
>
>        private static readonly ILog log =
> LogManager.GetLogger(typeof(Program));
>        static void Main(string[] args)
>        {
>            XmlConfigurator.Configure();
>            log.Info("Entering application.");
>            log.Debug("Exiting application.");
>            Console.Write("This Log4Net example");
>        }
>
> This thing is working well.
> And what i want to do is put the log4net configuration part in a separate
> file call Log4Net.config
>
> if any one know how to do this please reply me. It is better if u can
> separately give me the two configuration files. (App.config and
> Log4Net.config)
>
> thanks a lot
> wijitha
>
> --
> View this message in context:
> http://www.nabble.com/How-to-use-separate-config-file-for-log4net-tp20856712p20856712.html
> Sent from the Log4net - Users mailing list archive at Nabble.com.
>
>

Mime
View raw message