You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "G.L. Grobe" <ga...@grobe.net> on 2001/09/01 09:12:40 UTC

log4j in j2ee app

I just started working with Log4j and have a few questions about how to use
it w/ a j2ee app.

I don't know where to initialize the static Category so that my servlets,
actions (MVC using webwork), and ejb's can see it. I'm sure I don't init
this static category class in each servlet and every other entity that uses
it, but I'm also now sure how to use this in a j2ee app.

Also, I'm using JBoss and JBoss has a log4j.jar in the application classpath
so I'm thinking that means it uses the app classloader instead of the
web-app classloader to get at it (or a classloader at a high enough
hierarchy to access it).

Any help much appreciated.
TIA


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


Re: log4j in j2ee app

Posted by "G.L. Grobe" <ga...@grobe.net>.
sorry, dumb question. just woke up!

----- Original Message -----
From: "G.L. Grobe" <ga...@grobe.net>
To: "LOG4J Users Mailing List" <lo...@jakarta.apache.org>
Sent: Saturday, September 01, 2001 1:01 PM
Subject: Re: log4j in j2ee app


> So ... JBoss uses log4j, then I must be missing something else because I
> can't see the log4j.jar that's held in JBoss's ~/lib/ext dir (which I
think
> is in the app classpath)? The "import org.apache.log4j.Category;" I'm
adding
> to my ejb's are not being found when compiling. "Class
> org.apache.log4j.PropertyConfigurator not found in import."
>
> > JBoss uses log4j as its core logging system (though there are some parts
> > which need to be migrated).  It is loaded from the JMX MLet.  So every
> > component in JBoss (with a minor exception to the bootstrap code) has
> > complete access to the log4j api.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>


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


Re: log4j in j2ee app

Posted by "G.L. Grobe" <ga...@grobe.net>.
So ... JBoss uses log4j, then I must be missing something else because I
can't see the log4j.jar that's held in JBoss's ~/lib/ext dir (which I think
is in the app classpath)? The "import org.apache.log4j.Category;" I'm adding
to my ejb's are not being found when compiling. "Class
org.apache.log4j.PropertyConfigurator not found in import."

> JBoss uses log4j as its core logging system (though there are some parts
> which need to be migrated).  It is loaded from the JMX MLet.  So every
> component in JBoss (with a minor exception to the bootstrap code) has
> complete access to the log4j api.



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


Re: log4j in j2ee app

Posted by Jason Dillon <ja...@boldfish.com>.
> I don't know where to initialize the static Category so that my servlets,
> actions (MVC using webwork), and ejb's can see it. I'm sure I don't init
> this static category class in each servlet and every other entity that uses
> it, but I'm also now sure how to use this in a j2ee app.

Just put them where you need logging.  If UserManagerServlet needs some
logging, then you probably want to give it a category to log to.

If you want to log from an ejb, then put it in the EnterpriseBean subclass.

I have found that it is useful at times to have a logger/category per bean
instance, using a slightly altered category name which appends the hashCode
of the object radix 32.

As a rule of thumb, each class that needs to log has its own
logger/category, some static, some instances depending on how I feel.

Not sure if that helps, perhaps I am missing something.

> Also, I'm using JBoss and JBoss has a log4j.jar in the application classpath
> so I'm thinking that means it uses the app classloader instead of the
> web-app classloader to get at it (or a classloader at a high enough
> hierarchy to access it).

JBoss uses log4j as its core logging system (though there are some parts
which need to be migrated).  It is loaded from the JMX MLet.  So every
component in JBoss (with a minor exception to the bootstrap code) has
complete access to the log4j api.

--jason


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