commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ming Fai" <ming...@hongkong.com>
Subject RE: commons-logging in J2EE environment
Date Mon, 19 Apr 2004 07:42:04 GMT
The question is not directly relevant to commons-logging, but a JBoss
classloader issue. The question should be posted in the JBoss forum and/or
log4j mail list instead.

> > I am looking to know if there is a 3rd way which is using common-logging
and
> > have 2 different log4j.xml files such that my enterprise application 
> > will use my xml configuration and JBoss will use his.
> > can I achieve this?

Yes. The JBoss UnifiedClassLoader by default put everything under a single
classloader. So, in your application, it actually use the log4j.jar under
the Jboss (root) library. In order to use two log4j configuration, you need
to have two log4j instance running in two different classloaders. Check the
following steps:

1. For your EAR or WAR, put a jboss-app.xml under /META-INF, with the
following content
<jboss-app>
  <loader-repository>
    some.com:loader=TestApp.ear
  </loader-repository>
</jboss-app>

Note: "some.com:loader" is the JMX property name that need to follow the JMX
naming convention. This allow the EAR to be loaded in its own class loader.
As a result, the log4j logger instance you use in your code will be loaded
from your classloader instead of that of JBoss'

2. Prepare log4j in your application, for example, in a WAR
    - put log4j.xml under /WEB-INF/classes
        (or whatever way you like to configure log4j, this is not a matter
of JBoss)
    - put log4j.jar under /WEB-INF/lib

Note: check log4j manual for configuration. you don't even need to specify a
system property for log4j.


regards,
mingfai

> -----Original Message-----
> From: Guy Katz [mailto:gkatz@allot.com] 
> Sent: Thursday, April 15, 2004 5:29 PM
> To: 'Jakarta Commons Users List'
> Subject: RE: commons-logging in J2EE environment
> 
> 
> hi and thanks for the reply.
> actually, i think there is a difference between using a 
> package such as commons-logging and the specific log system 
> API. for example, with log4j i can use the DOMConfigurator to 
> explicitly load (in
> code) a configuration file of my own. in the common-logging 
> package this API is hidden from the user so the flexibility 
> is more limited. JBoss app server seems to use the 
> commons-logging package also. which is nice but than, like i 
> said, every file i configure (or use a default file) will be 
> shared by my app and the JBoss. i cant see any workaround 
> here so i will have to settle for sharing configuration. thanks.
> 
> 
> -----Original Message-----
> From: robert burrell donkin 
> [mailto:robertburrelldonkin@blueyonder.co.uk]
> Sent: Wednesday, April 14, 2004 11:25 PM
> To: Jakarta Commons Users List
> Subject: Re: commons-logging in J2EE environment
> 
> 
> hi guy
> 
> commons-logging doesn't really configure the logging system (log4j in 
> this case), the commons-logging configuration just chooses 
> the logging 
> system to be used. therefore, i think that the log4j configuration 
> should be transparent (in other words, the same whether you 
> call log4j 
> directly or through commons-logging).
> 
> i hope that this answers your question.
> 
> - robert
> 
> On 14 Apr 2004, at 17:41, Guy Katz wrote:
> 
> > hi all;
> > I just recently started working with the common-logging.
> > I am using JBOSS app server.
> > it seems I have 2 choices configuring my logging mechanism for my
> > application:
> > 1. adding my configuration to the log4j.xml already existing in the
> > JBOSS
> > directory.
> > 2. put a system property with the -Dlog4j... with my file 
> name and than
> > loose the JBOSS configuration (or add it to my file)
> > both method dont seem very good to me cause i dont want to 
> merge JBoss
> > configuration and my configuration.
> > I am looking to know if there is a 3rd way which is using 
> > common-logging and
> > have 2 different log4j.xml files such that my enterprise 
> application 
> > will
> > use my xml configuration and JBoss will use his.
> > can I achieve this?
> > i think with log4j i could have used the DOMConfigurator to load my
> > configuration as well. did i loose this ability using 
> commons-logging?
> > thanks for the help.
> >
> > ____________________
> > Guy Katz
> > Allot Communications
> > gkatz@allot.com
> > tel: +972 9 7619288
> > fax: +972 9 7443626
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: 
> commons-user-help@jakarta.apache.org
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message