Logging with JBoss as7 Logger

If you want log4j-style logging under a JBoss AS7 project, just include the seam solder jar which abstracts the log4j-logger and use the org.jboss.logging.Logger as log-provider.

For maven:

<dependency>
	<groupId>org.jboss.seam.solder</groupId>
	<artifactId>seam-solder</artifactId>
	<version>3.0.0.Final</version>
</dependency>

And if you want to use all loglevels you can change your loglevel in your standalone.xml file by changing the subsystem. I set the root logger and my own package to debug and made the others less verbose.

<subsystem xmlns="urn:jboss:domain:logging:1.1">
	<console-handler name="CONSOLE" autoflush="true">
		<level name="DEBUG" />
		<formatter>
			<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n" />
		</formatter>
	</console-handler>
	<periodic-rotating-file-handler name="FILE"
		autoflush="true">
		<level name="INFO" />
		<formatter>
			<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n" />
		</formatter>
		<file relative-to="jboss.server.log.dir" path="server.log" />
		<suffix value=".yyyy-MM-dd" />
		<append value="true" />
	</periodic-rotating-file-handler>
	<logger category="at.coffeebeans">
		<level name="DEBUG" />
	</logger>
	<logger category="com">
		<level name="INFO" />
	</logger>
	<logger category="sun">
		<level name="INFO" />
	</logger>
	<logger category="org">
		<level name="INFO" />
	</logger>
	<logger category="javax">
		<level name="INFO" />
	</logger>
	<root-logger>
		<level name="DEBUG" />
		<handlers>
			<handler name="CONSOLE" />
			<handler name="FILE" />
		</handlers>
	</root-logger>
</subsystem>

Don’t forget to restart your server after changing standalone.xml.

Leave a Comment