views:

116

answers:

3

It is possible to use jboss-log4j.xml as configuration file for my application ? I just want my application to log in the same place as Jboss server(console and file)...

A: 

If you want to use all the same logging rules as JBoss then you can reference your existing jboss-log4j.xml file from your app. Otherwise, you could just copy the relevant output sections into a separate file specific to your app. I would recommend the 2nd approach.

BenV
+1  A: 

JBoss uses a single global log4j configuration for every application. Any calls your app makes to log4j will be routed via the config in jboss-log4j.xml. You should feel free to modify that file to suit your application(s) - it determines which loggers use which files.

By default, your application(s) logs will will go to the same file(s) as JBoss itself logs to.

skaffman
I needed to call my class with this paramether:-Dlog4j.configuration=file:///C:\jboss-5.1.0.GA\server\all\conf\jboss-log4j.xmlin order for the jboss-log4j.xml properties to be considered.And I didn't yet find a way to log in the same console jboss is logging.
mariu
A: 

I have a war file that I deployed to JBOSS_HOME/server/default/deploy. I add the following to the JBOSS_HOME/server/default/conf/jboss-log4j.xml

I restart the server and expect the logger.debug() messages from the class com.ld.ids.service.* classes to show up in the server.log or console. But I dont' see anything but the INFO level messages, so looks like my change to jboss-log4j.xml is being ignored. I checked, for any other log4j.propeties or log4j.xml file in the war or included jars and didn't find any.

Then I turned the JVM flag -Dlog4j.debug=true and found that the JBOSS_HOME/bin/run.jar has a log4j.properties included with it and that's the file that is being used by JBoss to config the log4j. How do I tell Java or JBoss to use my BOSS_HOME/server/default/conf/jboss-log4j.xml

Any ideas? I am on JBoss 5.1.0 GA with JDK 1.6 on Mac os x 10.6

Thanks Vijay

Vijay Kumar
Can't you use -Dlog4j.configuration=<your_file>?
Marcel