How to install Logback Logger in Glassfish 3.1.1

How to install Logback Logger in Glassfish 3.1.1

1.) Download the ff jars:
a.) slf4j-api.jar
b.) jul-to-slf4j.jar
c.) logback-classic.jar
d.) logback-core.jar

2.) Copy the jars mentioned above in {glassfish_home}/glassfish/lib/endorsed.

3.) Modify domain.xml in {glassfish_home}/glassfish/domains/domain1/config/domain.xml. We assume that you did not create another domain for this exercise. Otherwise change domain1 to your desired domain.

4.) In the "java-config" section add the ff "jvm-options":
<jvm-options>-Dlog4j.configuration=file:///${com.sun.aas.instanceRoot}/config/custom_logging.properties</jvm-options>
<jvm-options>-Dlogback.configurationFile=file:///${com.sun.aas.instanceRoot}/config/logback.xml</jvm-options>
5.) The above 2 statements will configure logger and forward the logging statement to logback. custom_logging.properties
handlers = org.slf4j.bridge.SLF4JBridgeHandlercom.sun.enterprise.server.logging.GFFileHandler.flushFrequency=1
com.sun.enterprise.server.logging.GFFileHandler.file=${com.sun.aas.instanceRoot}/logs/server.log
com.sun.enterprise.server.logging.GFFileHandler.rotationTimelimitInMinutes=0
com.sun.enterprise.server.logging.GFFileHandler.logtoConsole=false
com.sun.enterprise.server.logging.GFFileHandler.rotationLimitInBytes=2000000
com.sun.enterprise.server.logging.GFFileHandler.alarms=false
com.sun.enterprise.server.logging.GFFileHandler.formatter=com.sun.enterprise.server.logging.UniformLogFormatter
com.sun.enterprise.server.logging.GFFileHandler.retainErrorsStasticsForHours=0
logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <!--<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d %5p | %t | %-55logger{55} | %m %n</pattern>
        </encoder>
    </appender>-->
     
    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <layout class="ch.qos.logback.classic.PatternLayout">
            <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
        </layout>
    </appender>
 
    <logger name="com.ipiel">
        <level value="debug" />
    </logger>
 
    <logger name="org.springframework">
        <level value="debug" />
    </logger>
 
    <root>
        <level value="debug" />
        <appender-ref ref="console" />
    </root>
</configuration>
How to install Logback Logger in Glassfish 3.1.1 How to install Logback Logger in Glassfish 3.1.1 Reviewed by Edward Legaspi on Tuesday, May 15, 2012 Rating: 5

No comments:

Powered by Blogger.