Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Liferay change log file location in portal-log4j.xml
I am trying to customize the log file name and location in cluster environment, so that each liferay instance creates it own log file.
I see this settings in portal-log4j.xml which tells the name and location of log file. My question is what is @spi.id@ property ?
<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>
Can I set @spi.id@ system property with the server name in a cluster, so that each server will have its own log file. Or it is meant for any purpose in liferay ?
Lets say for liferay instance 1, I set spi.id system property as server1 and for liferay instance 2, I set system property spi.id as server2, so that each instance will log to a file like liferayserver1.05-05-2016 and liferayserver2.05.05.2016.
Please suggest.
I see this settings in portal-log4j.xml which tells the name and location of log file. My question is what is @spi.id@ property ?
<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>
Can I set @spi.id@ system property with the server name in a cluster, so that each server will have its own log file. Or it is meant for any purpose in liferay ?
Lets say for liferay instance 1, I set spi.id system property as server1 and for liferay instance 2, I set system property spi.id as server2, so that each instance will log to a file like liferayserver1.05-05-2016 and liferayserver2.05.05.2016.
Please suggest.
Just create META-INF/portal-log4j-ext.xml files in each instance and set the different log files.
I am working on JBoss EAP. I tried to place META-INF/portal-log4j-ext.xml in com.liferay.portal module directory , but for some reason liferay is not finding it. I even kept it in a seperate jar and placed in com.liferay.portal modules directory still no luck.
Any suggestion on how to do it in Jboss EAP.
Any suggestion on how to do it in Jboss EAP.
Actually this spi.id solution seems pretty elegant to me, especially in a cloud environment.
I'm not sure what this variable was intended for but setting CATALINA_OPTS to -Dspi.id=$HOSTNAME helps to create instance specific log files that can be then stored in a shared volume
I'm not sure what this variable was intended for but setting CATALINA_OPTS to -Dspi.id=$HOSTNAME helps to create instance specific log files that can be then stored in a shared volume
Just to add some two cents around nomenclature. Refer to them as "servers" or "installations". the term INSTANCE means something very specific in Liferay as a single INSTALLATION of Liferay can manage multiple (Portal) Instances.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™