[jboss-user] [Installation, Configuration & DEPLOYMENT] - Re: TRACE level doesn't work

jaikiran do-not-reply at jboss.com
Fri Feb 1 04:29:44 EST 2008


Tried this on my local setup with JBoss-4.2.2. Got it working. Here's what you have to do:

1) Create a log4j.properties file and package it with your application and make it available in the classpath (i placed the log4j.properties file at the root of the EAR file). The log4j.properties looks like:

log4j.logger.org.myapp=TRACE


2) Also package the appropriate version of log4j jar with your application (this step and the next step are important because you will have to ensure that log4j initializes separately for your application and picks up the log4j.properties file). Place this log4j jar file in the application package so that it is made available in the classpath (i placed it in a folder named lib of the EAR file - remember that any jars in the lib folder of the EAR are by default added to the classpath and made available to the entire application, starting JBoss-4.2.x version).

3) Enable classloader isolation for your application. This is necessary as explained in step#2. You will have to create a jboss-app.xml file and place it in the META-INF folder of the EAR. The jboss-app.xml looks like:

  | <jboss-app>
  |  <loader-repository>
  |    org.myapp:loader=MyClassLoader
  |    <loader-repository-config>
  |       java2ParentDelegation=false
  |    </loader-repository-config>
  |  </loader-repository>
  |  
  | 
  |   
  | </jboss-app> 

This is how my EAR file looks like:

myApp.ear
  |   |
  |   |--- log4j.properties
  |   |
  |   |--- META-INF
  |   |     |
  |   |     |--- application.xml
  |   |     |
  |   |     |--- jboss-app.xml
  |   |
  |   |--- lib
  |   |     |
  |   |     |--- log4jxxx.jar

And finally the -Dlo4j.debug prints out the following message when i invoke my application (this is just a sample output):


  | 2008-02-01 13:24:01,231 INFO  [STDOUT] log4j: Trying to find [log4j.xml] using context classloader org.jboss.mx.loading.UnifiedClassLoader3 at 1038b78{ url=file:/D:/JBoss-4.2.2/jboss-4.2.2.GA/server/jaikiran/deploy/EJB3Persistence.ear/ ,addedOrder=45}.
  | 2008-02-01 13:24:01,247 INFO  [STDOUT] log4j: Trying to find [log4j.xml] using org.jboss.mx.loading.UnifiedClassLoader3 at 1038b78{ url=file:/D:/JBoss-4.2.2/jboss-4.2.2.GA/server/jaikiran/deploy/EJB3Persistence.ear/ ,addedOrder=45} class loader.
  | 2008-02-01 13:24:01,262 INFO  [STDOUT] log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
  | 2008-02-01 13:24:01,262 INFO  [STDOUT] log4j: Trying to find [log4j.properties] using context classloader org.jboss.mx.loading.UnifiedClassLoader3 at 1038b78{ url=file:/D:/JBoss-4.2.2/jboss-4.2.2.GA/server/jaikiran/deploy/EJB3Persistence.ear/ ,addedOrder=45}.
  | 2008-02-01 13:24:01,262 INFO  [STDOUT] log4j: Using URL [file:/D:/JBoss-4.2.2/jboss-4.2.2.GA/server/jaikiran/deploy/EJB3Persistence.ear/log4j.properties] for automatic log4j configuration.
  | 2008-02-01 13:24:01,262 INFO  [STDOUT] log4j: Reading configuration from URL file:/D:/JBoss-4.2.2/jboss-4.2.2.GA/server/jaikiran/deploy/EJB3Persistence.ear/log4j.properties
  | 2008-02-01 13:24:01,262 INFO  [STDOUT] log4j: Parsing for [root] with value=[DEBUG, stdout, logfile].
  | 2008-02-01 13:24:01,262 INFO  [STDOUT] log4j: Level token is [DEBUG].
  | 2008-02-01 13:24:01,262 INFO  [STDOUT] log4j: Category root set to DEBUG
  | 2008-02-01 13:24:01,278 INFO  [STDOUT] log4j: Parsing appender named "stdout".
  | 2008-02-01 13:24:01,309 INFO  [STDOUT] log4j: Parsing layout options for "stdout".
  | 2008-02-01 13:24:01,309 INFO  [STDOUT] log4j: Setting property [conversionPattern] to [%d %p [%c] - <%m>%n].
  | 2008-02-01 13:24:01,325 INFO  [STDOUT] log4j: End of parsing for "stdout".
  | 2008-02-01 13:24:01,325 INFO  [STDOUT] log4j: Parsed "stdout" options.
  | 2008-02-01 13:24:01,325 INFO  [STDOUT] log4j: Parsing appender named "logfile".
  | 2008-02-01 13:24:01,325 INFO  [STDOUT] log4j: Parsing layout options for "logfile".
  | 2008-02-01 13:24:01,325 INFO  [STDOUT] log4j: Setting property [conversionPattern] to [%d %p [%c] - %m%n].
  | 2008-02-01 13:24:01,325 INFO  [STDOUT] log4j: End of parsing for "logfile".
  | 2008-02-01 13:24:01,340 INFO  [STDOUT] log4j: Setting property [file] to [D:\JBoss-4.2.2\jboss-4.2.2.GA\server\jaikiran\log\test.log].
  | 2008-02-01 13:24:01,340 INFO  [STDOUT] log4j: Setting property [maxFileSize] to [512KB].
  | 2008-02-01 13:24:01,340 INFO  [STDOUT] log4j: Setting property [maxBackupIndex] to [3].
  | 2008-02-01 13:24:01,340 INFO  [STDOUT] log4j: setFile called: D:\JBoss-4.2.2\jboss-4.2.2.GA\server\jaikiran\log\test.log, true
  | 2008-02-01 13:24:01,356 INFO  [STDOUT] log4j: setFile ended
  | 2008-02-01 13:24:01,356 INFO  [STDOUT] log4j: Parsed "logfile" options.
  | 2008-02-01 13:24:01,356 INFO  [STDOUT] log4j: Parsing for [org.myapp] with value=[WARN].
  | 2008-02-01 13:24:01,356 INFO  [STDOUT] log4j: Level token is [WARN].
  | 2008-02-01 13:24:01,356 INFO  [STDOUT] log4j: Category org.myapp set to WARN
  | 2008-02-01 13:24:01,356 INFO  [STDOUT] log4j: Handling log4j.additivity.org.myapp=[null]
  | 2008-02-01 13:24:01,356 INFO  [STDOUT] log4j: Finished configuring.
  | 



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4125416#4125416

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4125416



More information about the jboss-user mailing list