To clarify for James, it is absolutely ok for log4j.jar to be in *both*
common/lib and each app's WEB-INF/lib... at least in the case of Tomcat where
it implements child-first classloading behavior.  Child-first classloading
makes it so that WEB-INF/lib/log4j.jar gets loaded in preference to any
log4j.jar in a parent classloader.  While apps can see common/lib or
shared/lib, they will first attempt to load libraries from WEB-INF/lib.  Only
if the libraries can't be found there will they be loaded from parent
classloaders.  This is why it is unnecessary to use a logger repository
selector under Tomcat standalone if you have log4j.jar in WEB-INF/lib and the
config file in WEB-INF/classes.  The only caveat here is Log4j's preference for
XML config files.  So, if the app is usinig a properties file in
WEB-INF/classes, there's no guarantee that it will be used if there is a
log4j.xml somewhere else in the webapp classloader (in the default package) or
a parent classloader.  By using a log4j.xml file in WEB-INF/classes, you
guarantee that it is used since WEB-INF/classes is loaded in preference to jars
in WEB-INF/lib or any other parent classloader.

So, with that established, let's look at what we have here....

There are a couple issues here.  One is that Bence wants Tomcat to use Log4j for
logging.  Of course, in order for this to happen, not only will log4j.jar need
to be in common/lib, but also commons-logging.jar (not commons-logging-api.jar,
BTW).  Without commons-logging, no log4j logging will occur for Tomcat.

Now for app logging.  Again, I doubt that hivemind depends directly on Log4j.  I
bet it depends on commons-logging.  So, not only do you want log4j.jar in
WEB-INF/lib, but also commons-logging.jar.

Try that and let me know how it went.

Jake

Quoting Takacs Bence <[EMAIL PROTECTED]>:

> Well, if I was not clear enough:
> My goal was: to catch the logs from the environment (tomcat and
> hivemind) and from applications too. My problem was: I didn't know where
> to put log4j.jar and log4j.properties...
>
> I tried many combinations:
> commons -- logs only tomcat inner logs
> shared -- logs for tomcat, hivemodule, and for all applications
> common+shared -- doesn't work
> apps -- logs only for the actual application
> common+apps -- logs for tomcat, hivemodule, and for all applications
> shared+apps -- doesn't work
> commons+shared+apps -- doesn't work
>
> Well, you said that the shared+common combination won't work. But I've
> tried it (that was only _one_ line in my recent mail)
>
> Additionally I cannot get the log4j out from my applications, because
> they don't run without it.
>
> So my latest seems-working configuration is:
> log4j.properties in the shared, it can catch all applications log, which
> has log4j.jar in it's WEB-INF/lib....
>
> Thanks:
>       Bence
>
>
> James Stauffer wrote:
> > On 8/17/06, Takacs Bence <[EMAIL PROTECTED]> wrote:
> >> Well, I've tried, but I have some "bugs"...
> >>
> >> I deployed two applications, both with their own log4j.jar, and
> >> properties file, and I put an other to ${catalina.home}/common/classes,
> >> and ${catalina.home}/common/lib. It seems to be working except the
> >> following "bugs":
> >
> > It sounds like you have a lo4j.jar in both webapps/app/WEB-INF/lib and
> > common/lib.  Don't do that!  You shouldn't have log4j.jar twice in the
> > same classloader (Thanks for the clarification Jake!).  If you tell us
> > how you want to configure log4j we can tell you where to put the
> > files.
> >
> > It sounds like you should have the log4j files under
> > webapps/app/WEB-INF and server.  If you have them under
> > webapps/app/WEB-INF then you definitely don't want them unde common or
> > shared because both of those are seen by the web apps.
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to