Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Joby KJ
Log 4j is not working in my portlet
October 16, 2012 8:08 AM
Answer

Joby KJ

Rank: Junior Member

Posts: 43

Join Date: July 13, 2012

Recent Posts

Dear All,
I have configured log4j in my portlet using xml file for file logging. But it is not working.


<?xml version="1.0"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration>
<appender name="file" class="org.apache.log4j.FileAppender">
<param name="Append" value="false"/>
<param name="File" value="D:/log/portal.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
</layout>
</appender>
<logger name="com.test" additivity="false">
<level value="info"/>
<appender-ref ref="file"/>
</logger>
<root>
<level value="info"/>
<appender-ref ref="file"/>
</root>
</log4j:configuration>


Please advice.

Thanks
Joby
Siby Mathew
RE: Log 4j is not working in my portlet
October 16, 2012 8:19 AM
Answer

Siby Mathew

Rank: Expert

Posts: 265

Join Date: March 4, 2011

Recent Posts

Hi Joby,
Did you place the above file in WEB-INF/src ?
Also I dont have the following in my configuration, do you need this line ?
1<param name="Append" value="false"/>


Thanks,
Siby
Joby KJ
RE: Log 4j is not working in my portlet
October 16, 2012 8:43 AM
Answer

Joby KJ

Rank: Junior Member

Posts: 43

Join Date: July 13, 2012

Recent Posts

I have palce the log4j.xml in WEB-INF/src and commented line "<param name="Append" value="false"/> " . Still not working
Siby Mathew
RE: Log 4j is not working in my portlet
October 16, 2012 8:48 AM
Answer

Siby Mathew

Rank: Expert

Posts: 265

Join Date: March 4, 2011

Recent Posts

Hi Joby,
Do you require the appender-ref here ? (Did you add it for the additivity property ?)
1<logger name="com.test" additivity="false">
2<level value="info"/>
3[b]<appender-ref ref="file"/>[/b]
4</logger>


Thanks,
Siby
David H Nebinger
RE: Log 4j is not working in my portlet
October 16, 2012 9:26 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11046

Join Date: September 1, 2006

Recent Posts

Joby KJ:
I have configured log4j in my portlet using xml file for file logging. But it is not working.


Many times it won't.

Liferay configures log4j for you and will not use your log4j.xml regardless of where you put it. If you are using a standard Liferay MVC portlet project, you should be using the Liferay logging facilities to log, and not your own logging configuration.
Joby KJ
RE: Log 4j is not working in my portlet
October 16, 2012 10:49 PM
Answer

Joby KJ

Rank: Junior Member

Posts: 43

Join Date: July 13, 2012

Recent Posts

Hi David,
Please tell me the name and path of that file. I possible mention sample configuration also.


thanks
Joby