JBoss Logging Got Ya Down?

Okay, I admit it, I like JBoss. Well, once I finally got the hang of it, that is. But logging was always something that drove me crazy. On my current project, my client is using Liferay portal and JBoss together, and let’s just say there was some friction. I used to get log messages that looked like this:

10:14:10,134 INFO  [stdout] (JMS Session Delivery Thread - DeidentifiedThreadId) INFO  - ==> Got message:

Notice the [stdout] next to the log message. Because of this, JBoss does not know how to control the logger. Many posts I read recommended putting org.apache.log4j as an exclusion in jboss-deployment-structure.xml. I did this and it did not work. If you are using JBoss EAP 6.x DO NOT DO THIS! READ ON!

First of all, I could never reliably get my log messages to show up (using log4j). Sometimes they would come out, sometimes they wouldn’t. It drove me nuts! We started using JBoss EAP 5 and have now upgraded to 6.1. There has been some pain.

First, we were using a jboss-deployment-structure.xml file to control dependencies (and exclusions). Until today, I had org.apache.log4j under <exclusions>. No more! My jboss-deployment-structure.xml went from this:

<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
  <deployment>
    <exclusions>
      <module name="org.apache.log4j" /> 
      <module name="org.hibernate" />
    </exclusions>
    <dependencies>
      <module name="org.apache.log4j" />
      <module name="com.liferay.portal" />
      <module name="javax.mail.api" />
      <module name="org.apache.xerces" />
      <module name="org.jboss.modules" />
      <module name="org.apache.cxf" />
    </dependencies>
  </deployment>
</jboss-deployment-structure>

To this:

<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
  <deployment>
    <exclusions>
    </exclusions>
    <dependencies>
      <module name="org.apache.log4j" /> 
      <module name="org.hibernate" />
      <module name="org.apache.log4j" />
      <module name="com.liferay.portal" />
      <module name="javax.mail.api" />
      <module name="org.apache.xerces" />
      <module name="org.jboss.modules" />
      <module name="org.apache.cxf" />
    </dependencies>
  </deployment>
</jboss-deployment-structure>

Now I can control log output through the JBoss console (or by changing standalone.xml directly). My log messages come out with the correct logger name and everything works.

Just thought I’d pass that along!

–jsp

About these ads

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 64 other followers

%d bloggers like this: