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:[EMAIL PROTECTED] > Sent: 21 July 2005 21:46 > To: [email protected] > 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. >
