Hello again.
I have tried something like this(i have found the factory class somewhere but i can't remember).
So i use
private static readonly ILog Log1 = LogFactory.tasos();
and
private static readonly ILog Log2 = LogFactory.tasos2();(different method on a different class but with the same code as above - of course using a different config file).
but again i have the same result....
Can you please send me some more info (maybe a url) about this one?

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)

Thanks again for your help!


On 10/11/2015 5:19 PM, piers.willi...@gmail.com wrote:

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!


Reply via email to