Tech-Today
How to enable slf4j logging in glassfish 3.1.1
This blog entry will try to setup slf4j as the main logger for glassfish 3.1.1
What you need:
1.) Glassfish 3.1.1 (zipped)
2.) Download the ff jars:
a.) slf4j-api.jar
b.) jul-to-slf4j.jar
c.) logback-classic.jar
d.) logback-core.jar
Steps
1.) Extract glassfish in the directory of your choice
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.
4.) In the "java-config" section add the ff "jvm-options":
<jvm-options>-Dlog4j.configuration=file:///${com.sun.aas.instanceRoot}/config/_logging.properties</jvm-options>
<jvm-options>-Dlogback.configurationFile=file:///${com.sun.aas.instanceRoot}/config/logback.xml</jvm-options>
The above 2 statements will configure logger and forward the logging statement to logback.
Content of _logging.properties
handlers = org.slf4j.bridge.SLF4JBridgeHandler
com.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">
<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.sido">
<level value="debug" />
</logger>
<logger name="org.springframework">
<level value="debug" />
</logger>
<root>
<level value="debug" />
<appender-ref ref="console" />
</root>
</configuration>
-
How To Monitor The Data Source Connections And Sql Queries In Jboss
To allow us to debug our jboss server for possible connection leaks, wrong sql queries normally we do 2 changes: 1.) In persistence.xml, set hibernate.show_sql to true 2.) In jboss's standalone.xml, we set the hibernate logger to DEBUG <logger...
-
How To Create Size-rotating-file Handler In Jboss 7.2 Using Cli
There are times when we require a size-rotating-file handler over the default periodic-rotating-file handler. Simply changing the properties in standalone.xml won't do because it will cause synch problem with logging.properties. So to do so we need...
-
How To Enable Remote Jvm Monitoring Using Jre's Built In Jconsole
This guide will help you setup a remote jvm monitoring tool using jconsole. The setup: 1.) Ubuntu 12.04 2.) Glassfish 3.1.2.2 3.) jdk1.6.0_32 Steps: 1.) In your glassfish's default domain1 domain.xml file, /glassfish_home/glassfish/domains/domain1/config/domain.xml,...
-
How To Load Property File From Glassfish Config's Folder
In seam you can define a component class in components.xml that will load the properties from the JBOSS_CONFIG folder. Add the ff lines: <component name="paramBean" class="com.ipil.PropertyBean" scope="application" auto-create="true" startup="true">...
-
How To Install And Setup Glassfish
1.) Download glassfish installer from http://download.java.net/glassfish/3.1.1/release/glassfish-3.1.1.zip 2.) Unzip in {your_choice}/glassfish-3.1.1 3.) Create 'startup' script file as follows: 4.) Create mydomain domain in glashfish: {your_choice}/glassfish-3.1.1/bin/asadmin...
Tech-Today