logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Karim Bourouba <kar...@hotmail.com>
Subject RE: relative path for config file
Date Thu, 06 Aug 2009 07:03:37 GMT

Hi There,
I understand you desire to have a central directory for log files - but surely if they are
all going to live in the \Configs dir, then this directory will always be in the same place
on each machine?
Other than that, I think unless you want to have a seperate utility to manage your logfiles
for you, then you will probably need to set the path in the code :(
Raszka - sometimes it is very useful to hold some configuration in an external xml file. 


Subject: RE: relative path for config file
Date: Thu, 6 Aug 2009 08:14:47 +0200
From: raszka@hasam.cz
To: log4net-user@logging.apache.org

you can try this:
<add key="log4net.Config.File" value="~\configs\log4net.config" />
but I'm not sure if this works. What you are using external config file? log4net config can
be written directly in web.config.

Od: Christian Chenier [mailto:cchenier@uottawa.ca] 
Odesláno: 5. srpna 2009 18:16
Komu: log4net-user@logging.apache.org
Předmět: relative path for config file

I use log4net in a C# web application and am having problems configuring it to use a relative
path to point to the location of a configuration file external to web.config.
In web.config, if I use
      <add key="log4net.Config.File" value="C:\somePath\log4net.config" />
all works fine. However, I would like to avoid having to hard-code the physical path and would
like to specify something like
      <add key="log4net.Config.File" value="configs\log4net.config" />
where the configs directory is located in the same directory as web.config (the AppDomain.CurrentDomain.BaseDirectory).
However this does not work (I no longer get anything output to my log file when I make that
I understand that one can programmatically construct a full path from the base directory,
but there is surely a way to specify a relative path directly in the web.config file? I have
tried modifying the string using leading slash (and backslash), etc. to no avail, and could
not find a solution anywhere. Does anyone know how to do this?
(As an aside, using a relative path to specify the output file name within the <appender>
works fine, relative to the base directory.)

Chris Chenier
Windows Live Messenger: Happy 10-Year Anniversary-get free winks and emoticons.
View raw message