WARNING: This server is unstable and will be retired in the next days. If you want to keep this forum available, please request immediately a migration on the Nabble Support forum. Forums that don't receive any migration request will be deleted forever.

 « Return to Thread: How to prevent creating log file ???

Re: How to prevent creating log file ???

by Stefan Bodewig :: Rate this Message:

| View in Thread

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.

Stefan

 « Return to Thread: How to prevent creating log file ???