Foren

Setting Liferay log configuration

Pepe Perez, geändert vor 11 Jahren.

Setting Liferay log configuration

New Member Beiträge: 14 Beitrittsdatum: 18.09.12 Neueste Beiträge
Hi,

I'm trying to set the Liferay log configuration, located at the "WEB-INF/lib/portal-impl.jar/META-INF/portal-log4j.xml" file. I'd like to set exactly the configuration of the appender called "FILE", from this:


<appender name="FILE" class="org.apache.log4j.rolling.RollingFileAppender">
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
<param name="FileNamePattern" value="@liferay.home@/logs/liferay.%d{yyyy-MM-dd}.log" />
</rollingPolicy>

<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}:%L] %m%n" />
</layout>
</appender>


to this:


<appender name="FILE" class="org.apache.log4j.rolling.RollingFileAppender">
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
<param name="ActiveFileName" value="@liferay.home@/logs/liferay.log" />
<param name="FileNamePattern" value="@liferay.home@/logs/liferay.%d{yyyy-MM-dd_HH-mm}.gz" />
</rollingPolicy>

<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}:%L] %m%n" />
</layout>
</appender>


but I'd like not to modify the "portal-impl.jar" file for this.

I've tried to insert a new "portal-log4j-ext.xml" file in "WEB-INF/classes/META-INF" folder and make this changes in it, but Log4J is taking both configurations, and creates a "liferay.%d{yyyy-MM-dd}.log" file too.

The only I'm thinking is to create a new ext plugin to make this. Is there another way to do it that I'm not considering?

Thanks.
thumbnail
Hitoshi Ozawa, geändert vor 11 Jahren.

RE: Setting Liferay log configuration

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
You seems to be doing it correctly.
http://www.liferay.com/community/wiki/-/wiki/Main/How+to+configure+the+logs+in+Liferay

Which version of liferay and which application server are you using?
Pepe Perez, geändert vor 11 Jahren.

RE: Setting Liferay log configuration

New Member Beiträge: 14 Beitrittsdatum: 18.09.12 Neueste Beiträge
Hi Hitoshi,

I'm using Liferay 6.1.1 CE GA2 with JBoss EAP 6.0.

Yes, according to documentation, I'm doing correctly creating the "portal-log4j-ext.xml" file and making my changes in it.

This is the code where Log4j is configured in Liferay:

public static void configureLog4J(ClassLoader classLoader) {
configureLog4J(classLoader.getResource("META-INF/portal-log4j.xml"));
configureLog4J(classLoader.getResource("META-INF/portal-log4j-ext.xml"));
}

Every configuration modified in "portal-log4j-ext.xml" file should overwrite the configuration declared in "portal-log4j.xml" file, but it seems that the log file is created before changes declared in the ext file are taken...
thumbnail
Puneet Malode, geändert vor 9 Jahren.

RE: Setting Liferay log configuration

New Member Beiträge: 17 Beitrittsdatum: 20.07.12 Neueste Beiträge
Hi Pepe,
I may be replying to old thread but it may help someone.

I am able to achieve what you are trying. I am using Liferay 6.1.20 EE with JBoss 7.1.1.

I placed 2 files under “D:\Liferay-6.1.20\jboss-7.1.1\standalone\deployments\ROOT.war\WEB-INF\classes\META-INF”.
1. log4j.dtd
2. portal-log4j-ext.xml

I think you missed the 1st file to place in that location.