Calfater Calfater - 1 year ago 118
Java Question

Log4j default placeholder value

I use log4j with this appender:

<appender name="fileAppenderRoot" class="org.apache.log4j.FileAppender">
<param name="file" value="${log.location}/logFile.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-5p [%c{1}] - %m%n" />

If I start the server with
, log4j will log into
but if I specify nothing, log4j will fail appending to

Is it possible to specify a default placeholder value?

Answer Source

No. you need to provide a location to write the log file.

If you need to generate the logs in the folder where you war is deployed ,

<param name="file" value="../logs/logFile.log" />

will create logfile in the folder where you have deployed

Read more here