logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wijitha <wijitha...@gmail.com>
Subject How to use separate config file for log4net
Date Fri, 05 Dec 2008 15:46:38 GMT

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" ?>
       <section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, 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" />

     Set root logger level to DEBUG and its only appender to A1 
      <level value="DEBUG" />
      <appender-ref ref="A1" />

here is the code:

        private static readonly ILog log =
        static void Main(string[] args)
            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

thanks a lot 

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.

View raw message