logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicko Cadell" <ni...@neoworks.com>
Subject RE: Why does the FileAppender create a zero byte file when logger is set to OFF?
Date Fri, 22 Jul 2005 12:08:56 GMT
The FileAppender is created and activated at configure time if it is
referenced from any of the <root> or <logger> elements. This is done
regardless of the <level> set on the logger. This is because the level
can be changed at runtime (e.g. programmatically) and the appender would
have to be ready to receive events immediately without going through an
activation cycle.

When the FileAppender is activated it will open the output file for
writing. This actually depends on the LockingModel, but in the default
ExclusiveLock model the appender will obtain the write lock on the file
as soon as possible. Obviously if the file does not exist it will be
created and this is what you are seeing.

It should be possible to create a custom locking model that is still
exclusive but defers file creation until the first message is logged.

Nicko

> -----Original Message-----
> From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
> Sent: 21 July 2005 21:46
> To: log4net-user@logging.apache.org
> Subject: Why does the FileAppender create a zero byte file 
> when logger is set to OFF?
> 
> When I set my root logger to OFF:
> 
>  <root>
>   <level value="OFF" />
>   <appender-ref ref="FileAppender" />
>  </root>
> 
> A zero byte output file for my FileAppender appender is still created.
> Why is this? I would expect no file to be created.
> 

Mime
View raw message