I have a log4j.xml file which is used by dozens of classes throughout the
day. One of these classes needs to log some data into a separate file, so I
created the following config:

<appender name="XXX" class="org.apache.log4j.DailyRollingFileAppender">
    <param name="File" value="../logs/XXX.log"/>
    <param name="Append" value="true"/>
    <param name="DatePattern" value="'.'yyyy-MM-dd" />
</appender>

<category name="a.b.c.XXXClass">
    <appender-ref ref="XXX" />
</category>

Although the XXX.log file is written to disk (albeit empty) every time the
log4j engine is initialised by the other classes.

Am I correct in saying that the Log4J engine will parse all appenders and
write any log files not on disk, to disk?

Is there a way to stop this? I only want the log file to be written onto
disk when XXXClass logs data.

Cheers in advance,

Niraj

Reply via email to