logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: How to prevent creating log file ???
Date Wed, 12 Oct 2011 14:22:11 GMT
On 2011-10-12, Sigourney_Weaver wrote:

> Hi I am using this configuration that is supposed to create one log file for
> business (INFO & ERROR) and another - for system errors (FATAL).

> http://old.nabble.com/file/p32638170/Fk2dH.png

> Both log files are created right away when I execute:
> LogManager.GetLogger(typeof(Program));
> I dont want SystemErrorsLog log file to be created, unless I actually log
> FATAL error, log.Fatal("System Error". Otherwise it would be just redundant
> empty log file. Is there any way this can be done, maybe some attribute I am
> not familiar with?

In general FileAppender opens the file immediately once it gets
configured.  In fact it is not FileAppender itself but the LockingModel
it uses.

At least with log4net 1.2.11 the MinimalLock locking model will not open
the file until the first message is logged.  It opens and closes the
file for each message.  While this might avoid the empty log file it
also implies a performance hit which may be quite significant if you
have many FATAL errors.  This may be acceptable if FATAL errors almost
never happen - which I'd hope to be the case.


View raw message