logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <piers.willi...@gmail.com>
Subject RE: unintended usage of the same configuration file
Date Sun, 11 Oct 2015 14:19:35 GMT
When you configure log4net using the assembly attribute, it is ‘first logging call wins’
as to which attribute gets actually used to configure log4net. Log4net is then configured
once, and so only one of those configs ever gets used. Hence all your logging going in the
same place.

This behaviour can be confusing at best - I’d recommend going for explicit logging initialization
in your app startup instead (imperative call to the various log4net Configurators). 

BTW if your original goal was to have logging from different parts of your app go out to different
files, then you can still do that, you’ll just have to do so via configuration in a single
logging file (ie by setting up two FileAppenders, and configuring different loggers (based
on the namespace conventions in your app) to point to each)


From: tasos
Sent: Sunday, 11 October 2015 10:26 AM
To: log4net-user@logging.apache.org
Subject: unintended usage of the same configuration file


Hello.
I'm working on a .net application and i have used this guidance http://haacked.com/archive/2005/03/07/ConfiguringLog4NetForWebApplications.aspx/
There is a project on which i have added in the assemblyinfo.cs
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "foo1.config", Watch = true)]
and in another one(different assembly)
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "foo2.config", Watch = true)]
My configurations are like this http://pastebin.com/UpSpwMHH
except the different output filenames
(<param name="File" value="foofilename.log"/> )
The problem is that the assembly that uses foo1.config writes on the output
file of the file that is configured in foo2.config.
In each class i use log4net i declare as the guidance site(mentioned above) says:
private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

Thank you in advance for your help!




Mime
View raw message