You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by pvphuc <pc...@yahoo.com.vn> on 2006/12/11 10:06:47 UTC

Problem with Log4Net.config file.

I create a file : Log4net.config in my project for Log4net configuration (I
do not want to write them in Web.config)
But I can not write to log file (for example : C:\\Log_file.txt).

(If I config in Web.config, Log_file.txt is updated)

Please tell me how I can use external Log4Net.config instead using
Web.Config.
(I am using ASP.Net 2.0)

Thanks in advance!
-- 
View this message in context: http://www.nabble.com/Problem-with-Log4Net.config-file.-tf2792725.html#a7791449
Sent from the Log4net - Users mailing list archive at Nabble.com.


RE: Problem with Log4Net.config file.

Posted by pvphuc <pc...@yahoo.com.vn>.
Thanks  Dean Fiala so much!
It is done correctly.

-- 
View this message in context: http://www.nabble.com/Problem-with-Log4Net.config-file.-tf2792725.html#a7826569
Sent from the Log4net - Users mailing list archive at Nabble.com.


RE: Problem with Log4Net.config file.

Posted by Dean Fiala <df...@celadonlabs.com>.
You need to use the XMLConfigurator to tell log4net where the file is.
Easiest place to do this in the Application_Start event handler.

In VB...

   'point it to the right place to find the config file
   Dim ConfigFile As String = Server.MapPath("~") & "\config\log4Net.config"
   XmlConfigurator.ConfigureAndWatch(New System.IO.FileInfo(ConfigFile))

In C#

    //point it to the right place to find the config file
   string ConfigFile = Server.MapPath("~") & @"\config\log4Net.config";
   XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(ConfigFile));

HTH,

Dean Fiala

Chief Technology Officer
Celadon Laboratories, Inc.
http://www.celadonlabs.com






-----Original Message-----
From: pvphuc [mailto:pcpvphuc@yahoo.com.vn] 
Sent: Monday, December 11, 2006 4:07 AM
To: log4net-user@logging.apache.org
Subject: Problem with Log4Net.config file.


I create a file : Log4net.config in my project for Log4net configuration (I
do not want to write them in Web.config) But I can not write to log file
(for example : C:\\Log_file.txt).

(If I config in Web.config, Log_file.txt is updated)

Please tell me how I can use external Log4Net.config instead using
Web.Config.
(I am using ASP.Net 2.0)

Thanks in advance!
--
View this message in context:
http://www.nabble.com/Problem-with-Log4Net.config-file.-tf2792725.html#a7791
449
Sent from the Log4net - Users mailing list archive at Nabble.com.