This article documents how to change the Liferay logs directory from the default
[LIFERAY_HOME]/logs
to another desired path. Resolution
Steps to Change the Liferay Logs Directory
- Unzip the files
log4j.dtd
andportal-log4j.xml
from[Liferay WAR]/WEB-INF/lib/portal-impl.jar
- Move
log4j.dtd
andportal-log4j.xml
to[Liferay WAR]/WEB-INF/classes/META-INF
- Rename
portal-log4j.xml
toportal-log4j-ext.xml
- Edit
portal-log4j-ext.xml
and delete all the category tags and keep only the needed tags, like the example below:
<?xml version="1.0"?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="FILE" class="org.apache.log4j.rolling.RollingFileAppender"> <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy"> <param name="FileNamePattern" value="@liferay.home@/logs/liferay@spi.id@.%d{yyyy-MM-dd}.log" /> </rollingPolicy> <layout class="org.apache.log4j.EnhancedPatternLayout"> <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}:%L] %m%n" /> </layout> </appender> <root> <priority value="INFO" /> <appender-ref ref="FILE" /> </root> </log4j:configuration>
In the param tag that contains:
value="$liferay.home/logs/liferay@spi.id@.%d{yyyy-MM-dd}.log"
You must change $liferay.home/logs/liferay to the path where you want the logs to be created. See the following example:
value="/var/logs/liferay@spi.id@.%d{yyyy-MM-dd}.log"
Additional Information
The [LIFERAY_HOME]/logs
files will still be created but will be empty files and not contain any data.