Foros de discusión

i'm not able set my log file

thumbnail
Michel Wicky, modificado hace 12 años.

i'm not able set my log file

Regular Member Mensajes: 130 Fecha de incorporación: 3/07/10 Mensajes recientes
I'm encountering very serious problem with classes generated with services builder and would like to debug my portlet to better understand what/where the problem is.

Is setted a log file in log4j.properties in ..\ROOT\WEB-INF\classes

log4j.rootCategory=DEBUG, CONSOLE

log4j.appender.CONSOLE=org.apache.log4j.FileAppender
log4j.appender.CONSOLE.File=C:/liferay-portal-6.0.6/tomcat-6.0.29/logs/liferay.log
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}:%L] %m%n

I setted level to DEBUG for hibernate into portal-log4j-ext.xml in ..\ROOT\WEB-INF\classes\META-INF

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

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<category name="org.hibernate">
<priority value="DEBUG" />
</category>
</log4j:configuration>

After restarting the server, i got a liferay.log file but with only some DEBUG into not related to hibernate ... at the console however i can see a lot of new entry ... what i'm doing wrong ! both setting seem providing some result but why in the hell what i see on the console is not in my log file ?

Second question, i would like to debug my portlet and not all server activity ... is it a way to define the log level only for hibernate for what is executed by the portlet ?

Any help would be appreciate as it is to solve what i think is a bug in generated service builder classes !
thumbnail
Adolfo Enrique Benedetti, modificado hace 12 años.

RE: i'm not able set my log file

Junior Member Mensajes: 45 Fecha de incorporación: 4/06/09 Mensajes recientes
You can use the liferay log, like in this hook example;
....
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
.....
public class MyListener extends BaseModelListener<group> {
private static Log _log = LogFactoryUtil.getLog(MyListener.class);
......
  @Override
  public void onAfterCreate(Group group) throws ModelListenerException {
    _log.info(......);
.......</group>

This works on liferay 6.0.5
thumbnail
Michel Wicky, modificado hace 12 años.

RE: i'm not able set my log file

Regular Member Mensajes: 130 Fecha de incorporación: 3/07/10 Mensajes recientes
Thank you Andolfo, that's not the question but it is helpful because it is an information for the next step in my development.
I would like to debug org.hibernate and i'm able to but only on the console. I'm not able to configure this entry to be appended in the log file. That's my current problem.
thumbnail
jelmer kuperus, modificado hace 12 años.

RE: i'm not able set my log file

Liferay Legend Mensajes: 1191 Fecha de incorporación: 10/03/10 Mensajes recientes
Try removing the entries you made in log4j.properties
and instead add the following entries to your portal-log4j-ext.xml


    <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="${catalina.base}/logs/liferay.log">
        <param name="Append" value="true">
        <layout class="org.apache.log4j.PatternLayout">
	    <param name="ConversionPattern" value="%d %p [%c] - %m%n">
        </layout>
    </appender>


    <root>
        <appender-ref ref="FILE" />
    </root>
thumbnail
Michel Wicky, modificado hace 12 años.

RE: i'm not able set my log file

Regular Member Mensajes: 130 Fecha de incorporación: 3/07/10 Mensajes recientes
I got some warning when setting the parameters as you mentionned.

log4j:WARN Continuable parsing error 6 and column 13
log4j:WARN The content of element type "root" must match "(param*,(priority|level)?,appender-ref*)".
log4j:WARN Continuable parsing error 12 and column 19
log4j:WARN The content of element type "layout" must match "(param)*".
log4j:WARN Continuable parsing error 13 and column 17
log4j:WARN The content of element type "appender" must match "(errorHandler?,param*,rollingPolicy?,triggeringPolicy?,connectionSource?,layout?,filter*,appender-ref*)".
log4j:WARN Continuable parsing error 17 and column 23
log4j:WARN The content of element type "log4j:configuration" must match "(renderer*,appender*,plugin*,(category|logger)*,root?,(categoryFactory|loggerFactory)?)".
Starting Liferay Portal Community Edition 6.0.6 CE (Bunyan / Build 6006 / February 17, 2011)

Here is my file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<root>
2 <appender-ref ref="FILE"/>
3 </root>
<appender name="FILE" class="org.apache.log4j.RollingFileAppender">
2 <param name="File" value="${catalina.base}/logs/liferay.log"/>
3 <param name="Append" value="true"/>
4 <layout class="org.apache.log4j.PatternLayout">
5 <param name="ConversionPattern" value="%d %p [%c] - %m%n"/>
6 </layout>
7 </appender>
<category name="org.hibernate">
<priority value="DEBUG"/>
</category>
</log4j:configuration>
Yan Naing Oo, modificado hace 12 años.

RE: i'm not able set my log file

Regular Member Mensajes: 179 Fecha de incorporación: 17/02/11 Mensajes recientes
jelmer kuperus:
Try removing the entries you made in log4j.properties
and instead add the following entries to your portal-log4j-ext.xml


    <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="${catalina.base}/logs/liferay.log">
        <param name="Append" value="true">
        <layout class="org.apache.log4j.PatternLayout">
	    <param name="ConversionPattern" value="%d %p [%c] - %m%n">
        </layout>
    </appender>


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





I m using 6.0.6 the portal-log4j-ext.xml place it in webapps\ROOT\WEB-INF\classes. then no logs is see
any suggestion ?
Yan Naing Oo, modificado hace 11 años.

RE: i'm not able set my log file

Regular Member Mensajes: 179 Fecha de incorporación: 17/02/11 Mensajes recientes
Hello,

I have figured out the logs file out issues. below is the step to follow

1. create portal-log4j-ext.xml
2. create META-INF under ROOT\WEB-INF\classes\ .. then place it the portal-log4-ext file

Inside code below

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<root>
<appender-ref ref="FILE"/>
</root>

<appender name="FILE" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="${catalina.base}/logs/liferay.log"/>
<param name="Append" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %p [%c] - %m%n"/>
</layout>
</appender>

<category name="org.hibernate">
<priority value="ERROR"/>
<priority value="WARN"/>
</category>
</log4j:configuration>


then it will write out in liferay.log file whenever get the error or warning etc..
thumbnail
David H Nebinger, modificado hace 11 años.

RE: i'm not able set my log file

Liferay Legend Mensajes: 14915 Fecha de incorporación: 2/09/06 Mensajes recientes
Michel Wicky:
I'm encountering very serious problem with classes generated with services builder and would like to debug my portlet to better understand what/where the problem is.


Your problem is that you assume you can do your own logging implementation for service builder entities, which is incorrect.

You should be using the Liferay logging API as another user has suggested. You should add your logging to the portal-ext-log4j.xml in ROOT's WEB-INF/classes.

If you try using your own log4j instance, you'll end up w/ class loader issues since the log4j instance is actually ROOT's and not your own, and therefore it will not be able to load your log4j.xml file as a result.

We don't like using Liferay's logging api (we prefer that our individual portlets have their own logging files so we don't have to weed through Liferay's logs and filter stuff out). So for our service providing plugin, that one (and only that one) leverages the Liferay logging API. The rest of the portlets (since their not tightly coupled w/ the lower level integration stuff that a service builder entity is) uses their own log4j logging pretty much w/o any issue.