Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Liferay Integaration with Log4j

    • 0
    • 3
    • 3
    • 1
    • 0
    • 0
    • 0
    • 0
    • 1.02k
    Comment on it

    Liferay+Log4j:- This blog will show you how you can implement logging in Liferay with Log4j. By using this you can use the custom logging using Log4j in Lifeary. To make this possible follow the below steps:-
    1. Create log4j.xml and log4j.dtd file inside the src folder of your Portlet.


    I have taken the log4j.dtd from the liferay portal source.


     <?xml version="1.0"?>
        <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
        <log4j:configuration xmlns:log4j="">
            <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
                <layout class="org.apache.log4j.PatternLayout">
                    <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}:%L] %m%n" />
            <appender name="FILE" class="org.apache.log4j.rolling.RollingFileAppender">
                <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
                    <param name="FileNamePattern" value="${catalina.base}/logs/dentalNote.%d{yyyy-MM-dd}.log" />
                <layout class="org.apache.log4j.PatternLayout">
                    <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}:%L] %m%n" />
            <category name="com.myclient" >
                <priority value="TRACE" />
                <priority value="INFO" />
                <appender-ref ref="CONSOLE" />
                <appender-ref ref="FILE" />

    2. Modify the add the below code at bottom.


    3. At last you need to setup your logger in your class.

    private static Logger logger = Logger.getLogger(PatientSearch.class);"Hello Controller");

    NOTE:- See your log file inside the liferay-portal-6.2-ce-ga2/tomcat/logs folder.

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: