Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
James Smith
log4j in Liferay 6.1 - JBoss 7
April 8, 2012 3:46 AM
Answer

James Smith

Rank: Junior Member

Posts: 29

Join Date: February 10, 2012

Recent Posts

Hi,
I am trying to add debugging to my portlets using log4j but there is no instructions on how to do this for JBoss distribution. I have tried adding the to standalone.xml, but I still don't see anything in the server.log. Can somebody help me? emoticon

Thanks

James
Hitoshi Ozawa
RE: log4j in Liferay 6.1 - JBoss 7
April 8, 2012 6:41 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

You'll have to edit JBoss's log4j.xml file.

%JBOSS_HOME%\server\default\deploy\jboss-logging.xml
James Smith
RE: log4j in Liferay 6.1 - JBoss 7
April 8, 2012 12:09 PM
Answer

James Smith

Rank: Junior Member

Posts: 29

Join Date: February 10, 2012

Recent Posts

Hitoshi,
Thank you for the reply. I tried to look for jboss-logging.xml in the liferay 6.1's directory, but unable to find it. Can you tell me the fullpath?
I was searching in all directories under \liferay-portal-6.1.0-ce-ga1\jboss-7.0.2.

Hitoshi Ozawa:
You'll have to edit JBoss's log4j.xml file.

%JBOSS_HOME%\server\default\deploy\jboss-logging.xml
Hitoshi Ozawa
RE: log4j in Liferay 6.1 - JBoss 7
April 8, 2012 2:52 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Sorry, given you the one for 6.0.6 which was the one I was working when I answered.

On 6.1.0GA1, it's the file below:
liferay-portal-6.1.0-ce-ga1\jboss-7.0.2\standalone\configuration\logging.properties
James Smith
RE: log4j in Liferay 6.1 - JBoss 7
April 8, 2012 4:43 PM
Answer

James Smith

Rank: Junior Member

Posts: 29

Join Date: February 10, 2012

Recent Posts

Hitoshi,
I found the logging properties and I am trying to add logging for com.website.login classes such as LoginPortlet (see below), but I don't see anything showing up in the liferay-portal-6.1.0-ce-ga1\jboss-7.0.2\standalone\log\server.log. Do you know what I am missing...? I don't see "Inside Login()!!!" in the server.log

logging.properties:

# Additional logger names to configure (root logger is always configured)
loggers=org.jboss.as.config,com.website.login

# Dump system environment at boot by default
logger.org.jboss.as.config.level=DEBUG
logger.com.website.login.level=DEBUG

# Root logger level
logger.level=${jboss.boot.server.log.level:INFO}
# Root logger handlers
logger.handlers=FILE,CONSOLE

# Console handler configuration
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
handler.CONSOLE.properties=autoFlush
handler.CONSOLE.level=${jboss.boot.server.log.console.level:INFO}
handler.CONSOLE.autoFlush=true
handler.CONSOLE.formatter=PATTERN

# File handler configuration
handler.FILE=org.jboss.logmanager.handlers.FileHandler
handler.FILE.level=DEBUG
handler.FILE.properties=autoFlush,fileName
handler.FILE.autoFlush=true
handler.FILE.fileName=${org.jboss.boot.log.file:boot.log}
handler.FILE.formatter=PATTERN

# Formatter pattern configuration
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.PATTERN.properties=pattern
formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n


com.website.login.LoginPortlet:

package com.website.login;

import org.apache.log4j.Logger;


public class LoginPortlet extends GenericPortlet
{
protected static final Logger LOGGER = Logger.getLogger(LoginPortlet.class);

public void login(ActionRequest request, ActionResponse response)
throws PortletException, IOException
{
if(LOGGER.isDebugEnabled())
{
LOGGER.debug("Inside Login()!!!");
}
}

}


Hitoshi Ozawa:
Sorry, given you the one for 6.0.6 which was the one I was working when I answered.

On 6.1.0GA1, it's the file below:
liferay-portal-6.1.0-ce-ga1\jboss-7.0.2\standalone\configuration\logging.properties
Hitoshi Ozawa
RE: log4j in Liferay 6.1 - JBoss 7
April 8, 2012 4:57 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Have you seen this comment? I've tried setting up log4j properties in each portlet and remember that JBoss was ignoring them and using it's own. But I got it working it my environment so I know it's possible.

https://community.jboss.org/thread/173567
James Smith
RE: log4j in Liferay 6.1 - JBoss 7
April 8, 2012 10:54 PM
Answer

James Smith

Rank: Junior Member

Posts: 29

Join Date: February 10, 2012

Recent Posts

Hitoshi,
I looked into the URL and did the following, but the debug statement still not showing up in the server.log...do you know why? I am rather a newbie..please help.:
1, Copy the log4j.xml to liferay-plugins-sdk-6.1.0-ce-ga1-20120106155615760\portlets\login-portlet\docroot\WEB-INF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>

<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority Message\n -->
<param name="ConversionPattern" value="[logging/log4j.xml]: %C %m %n"/>
</layout>
</appender>

<category name="com.website.login">
<priority value="DEBUG"/>
</category>

<root>
<appender-ref ref="CONSOLE"/>
</root>

</log4j:configuration>


2. Copy log4j-1.2.16.jar to liferay-plugins-sdk-6.1.0-ce-ga1-20120106155615760\portlets\login-portlet\docroot\WEB-INF\lib
3. Copy jboss-deployment-structure.xml to liferay-plugins-sdk-6.1.0-ce-ga1-20120106155615760\portlets\login-portlet\WebContent\META-INF
<jboss-deployment-structure>

<module name="deployment.org.apache.log4j" >
<resources>
<resource-root path="log4j-1.2.16.jar" />
</resources>
<dependencies>
<module name="javaee.api"/>
</dependencies>
</module>

</jboss-deployment-structure>

4. Update liferay-plugins-sdk-6.1.0-ce-ga1-20120106155615760\portlets\login-portlet\WebContent\META-INF to become:
Manifest-Version: 1.0
Class-Path: 'org.apache.log4j'






Hitoshi Ozawa:
Have you seen this comment? I've tried setting up log4j properties in each portlet and remember that JBoss was ignoring them and using it's own. But I got it working it my environment so I know it's possible.

https://community.jboss.org/thread/173567
Hitesh Methani
RE: log4j in Liferay 6.1 - JBoss 7
April 8, 2012 11:44 PM
Answer

Hitesh Methani

Rank: Regular Member

Posts: 171

Join Date: June 24, 2010

Recent Posts

Hi James,
Even I had the issue with logs not printing in server.log, in liferay-portal-jboss-6.0-ee, the issue was resolved by removing log4j-extras.jar from ROOT.war/WEB-INF/lib
and restarting the server.

Try following it, hope it helps.

Thanks and Regards,
Hitesh Methani
James Smith
RE: log4j in Liferay 6.1 - JBoss 7
April 9, 2012 11:26 AM
Answer

James Smith

Rank: Junior Member

Posts: 29

Join Date: February 10, 2012

Recent Posts

Hi Hitesh,
Thank you for your suggestion. I removed the jar and restart, but I still don't see my debugging statement in the server.log. I am using liferay-portal-6.1.0-ce-ga1.

Anybody can help..?

Thanks


Hitesh Methani:
Hi James,
Even I had the issue with logs not printing in server.log, in liferay-portal-jboss-6.0-ee, the issue was resolved by removing log4j-extras.jar from ROOT.war/WEB-INF/lib
and restarting the server.

Try following it, hope it helps.

Thanks and Regards,
Hitesh Methani
James Smith
RE: log4j in Liferay 6.1 - JBoss 7
April 11, 2012 11:20 AM
Answer

James Smith

Rank: Junior Member

Posts: 29

Join Date: February 10, 2012

Recent Posts

Anybody can help me with the logging...? emoticon I am stuck...any help is appreciated...

James Smith:
Hi Hitesh,
Thank you for your suggestion. I removed the jar and restart, but I still don't see my debugging statement in the server.log. I am using liferay-portal-6.1.0-ce-ga1.

Anybody can help..?

Thanks


Hitesh Methani:
Hi James,
Even I had the issue with logs not printing in server.log, in liferay-portal-jboss-6.0-ee, the issue was resolved by removing log4j-extras.jar from ROOT.war/WEB-INF/lib
and restarting the server.

Try following it, hope it helps.

Thanks and Regards,
Hitesh Methani
Brian Chan
RE: log4j in Liferay 6.1 - JBoss 7
May 18, 2012 11:26 AM
Answer

Brian Chan

LIFERAY STAFF

Rank: Liferay Master

Posts: 751

Join Date: August 4, 2004

Recent Posts

This is fixed in LPS-27399. We found a workaround for a bug in JBoss AS7-514.

See fix in https://github.com/liferay/liferay-portal/commit/b6746abd603c2c36d50480371775034856e5e00e

It's just adding:

1
2<module name="org.apache.log4j" />


to jboss-deployment-structure.xml

Make sure to add it to the exclusions block, and not the dependencies block.
James Smith
RE: log4j in Liferay 6.1 - JBoss 7
October 22, 2012 11:34 PM
Answer

James Smith

Rank: Junior Member

Posts: 29

Join Date: February 10, 2012

Recent Posts

Hi Brian,
Thank you for replying. Can you tell me steps to implement this fix? I am a newbie and did the following steps without any result:

1. Added log4j-1.2.16.jar to liferay-plugins-sdk-6.1.0-ce-ga1-20120106155615760-dev\portlets\login-portlet\docroot\WEB-INF\lib
2. Added this jboss-deployment-structure.xml from liferay-portal-6.1.0-ce-ga1-dev\jboss-7.0.2\standalone\deployments\ROOT.war\WEB-INF and
modified it to become jboss-deployment-structure.xml under liferay-plugins-sdk-6.1.0-ce-ga1-20120106155615760-dev\portlets\login-portlet\docroot\WEB-INF.
I honestly not sure how this jboss-deployment-structure is for as I just copy and modify. Pardon me I am trying to test if this fix is viable quickly.

<?xml version="1.0"?>

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<exclusions>
<module name="org.hibernate" />
<module name="org.apache.log4j" />
</exclusions>
<dependencies>
<module name="javaee.api"/>
<module name="com.liferay.portal" />
<module name="javax.mail.api" />
<module name="org.apache.xerces" />
<module name="org.jboss.modules" />
<module name="system" export="false">
<imports>
<include path="com/sun/jmx"/>
<exclude path="/**" />
</imports>
</module>
</dependencies>
</deployment>
</jboss-deployment-structure>

3. Added the log4j code into SpringMVC Portlet Controller:

import org.springframework.web.portlet.mvc.AbstractController;

public class TestController extends AbstractController
{
protected static final Logger LOGGER = Logger.getLogger(TestController .class);

public void handleActionRequestInternal(ActionRequest request,
ActionResponse response)
throws Exception
{
LOGGER.debug("LOGGER.debug: TestController.handleActionRequestInternal() ???????????");
...
}
public ModelAndView handleRenderRequestInternal(RenderRequest request,
RenderResponse response)
throws Exception
{
LOGGER.debug("LOGGER.debug: TestController.handleRenderRequestInternal() ???????????");
...
}
}

4. I added the following log4j.xml into liferay-plugins-sdk-6.1.0-ce-ga1-20120106155615760-dev\portlets\login-portlet\docroot\WEB-INF

<?xml version="1.0"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="test.log" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value=":%p:%r:%c{1}: %m%n"></param>
</layout>
</appender>
<!-- logging level for all other unspecified loggers -->
<root>
<level value="debug"></level>
<appender-ref ref="test.log"></appender-ref>
</root>
</log4j:configuration>

Everything was successfully deployed, but I could not find test.log anywhere in the \liferay-portal-6.1.0-ce-ga1-dev

Please help! thank you

Brian Chan:
This is fixed in LPS-27399. We found a workaround for a bug in JBoss AS7-514.

See fix in https://github.com/liferay/liferay-portal/commit/b6746abd603c2c36d50480371775034856e5e00e

It's just adding:

1
2<module name="org.apache.log4j" />


to jboss-deployment-structure.xml

Make sure to add it to the exclusions block, and not the dependencies block.
Muthukumaran Madialagan
RE: log4j in Liferay 6.1 - JBoss 7
December 4, 2012 11:12 AM
Answer

Muthukumaran Madialagan

Rank: New Member

Posts: 8

Join Date: October 26, 2012

Recent Posts

Hi Smith,

I am having the same issue as you have described. I am using Liferay 6.1 & JBoss7. None of my logger statements are showing either on the Console nor in the server.log.

Did you fix your issue? any suggestion would be highly appreciated.

Thanks,
Muthu
Muthukumaran Madialagan
RE: log4j in Liferay 6.1 - JBoss 7
December 5, 2012 10:39 AM
Answer

Muthukumaran Madialagan

Rank: New Member

Posts: 8

Join Date: October 26, 2012

Recent Posts

I found a solution to this, after adding "-Dorg.jboss.as.logging.per-deployment=false" to the startup conf file, all the logs started to showed up

I found the solution in this thread https://community.jboss.org/thread/199923