I am trying to update my code from Jboss 5.1 to Jboss 7 , i figured out that jboss-as-7.1 has its own logging framework . I want to know major differences and advantages of using jboss's own logging framework over log4j . I also need an example of how I can use appender in this framework .
The built-in logging module of JBoss 7 is based on Java Util Logging. The main (only?) reason for using it is that it is already integrated and that it is not as trivial as one might hope to roll your own solution. You can use the provided SLF API if you don't want to use the JUL API.
You can configure the appenders in the instance config files like the standalone.xml
. Look for the logging subsystem config:
<profile>
<subsystem xmlns="urn:jboss:domain:logging:1.1">
it comes with a working example configuration. Please note that what is commonly called appender
is titled *handler
in the configuration, like console-handler
or periodic-rotating-file-handler
.
Here you can find some advice on the logging configuration.
EDIT : some clarification.
To say it differently - there is no real reason why you should prefer using the built-in jboss logging over your framework of choice. The only thing is that configuring your own framework will require additional effort and may still fail (I have spent some time figuring out how to configure my JBoss to use logback - and finally gave up). So I am not qualified to tell you how to keep your log4j implementation :)
You can use jboss logging either over the "native" JUL API, or over the SLF4J bridge. Both are included in the /modules
directory, so you don't need to include any addidtional libraries at runtime. Just request your preferred Logger
in your code and you're good to go:
SLF: LoggerFactory.getLogger(...);
JUL: Logger.getLogger(...);
The only thing I had to do to in order to switch from JUL to SLF was to provide the SLF API for the code to compile - here is the maven config:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
<scope>provided</scope>
</dependency>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With