Hi
First, thanks for replying me.
now that is working.
but now i wanna know, Should this piece of code be written in constructor
of each class i write.
FileInfo log4NetConfigFile = new FileInfo("log4net.config");
if (log4NetConfigFile == null || !log4NetConfigFile.Exists) throw new
Exception("unable to find log file");
log4net.Config.XmlConfigurator.ConfigureAndWatch(log4NetConfigFile);
thank you
wijitha
[EMAIL PROTECTED] wrote:
>
>
>
> // initialize the log4net config file
>
> // the system expects to find it in the same folder as the exe file =
> /bin/debug
>
> FileInfo log4NetConfigFile = new FileInfo ( "MyCustomConfigFile.config"
> );
>
> if (log4NetConfigFile == null || ! log4NetConfigFile.Exists) throw new
> Exception ( "unable to find log4net log file" );
>
> XmlConfigurator .Configure(log4NetConfigFile);
>
>
>
> ----------------------------------------
>
> From: "wijitha" <[EMAIL PROTECTED]>
> Sent: Friday, December 05, 2008 10:14 AM
> To: [email protected]
> Subject: How to use separate config file for log4net
>
> Hi all
>
> I want to use log4net with my project.
> here is the simple example i tried.
>
> App.config :
>
> type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
>
> A1 is set to be a ConsoleAppender
>
> A1 uses PatternLayout
>
> Set root logger level to DEBUG and its only appender to A1
>
> 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-tp20856712
> p20856712.html
> Sent from the Log4net - Users mailing list archive at Nabble.com.
>
>
>
>
--
View this message in context:
http://www.nabble.com/How-to-use-separate-config-file-for-log4net-tp20856712p20870124.html
Sent from the Log4net - Users mailing list archive at Nabble.com.