logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julien ALLANOS <julien.alla...@aql.fr>
Subject Re: logging configurations confusion
Date Fri, 10 Dec 2004 09:54:29 GMT
Selon Jacob Kjome <hoju@visi.com>:

> Quoting Julien ALLANOS <julien.allanos@aql.fr>:
>
> > Hi,
> >
> > I'm trying to get log4j working with my webapps. I have 2 webapp running on
> > the
> > same Tomcat 5.5 server, each one with its own log4j.rootLogger configured
> to
> > log to stdout.
> >
> > So I expect to get logs from webapp1 and webapp2 in catalina.out. Each root
> > logger has its own pattern and log level, so I can distinguish between the
> > two
> > in catalina.out. However, it seems they share the same logging
> configuration,
> > so I get only one pattern for the two webapps. Is this the normal
> behaviour?
> >
> > Let's get into details:
> >
> > webapp1
> > =3D=3D=3D=3D=3D=3D=3D
> > /webapp1/WEB-INF/web.xml
> > ------------------------
> > [...]
> >   <servlet>
> >     <servlet-name>log4j-init</servlet-name>
> >     <servlet-class>wave.util.Log4jInit</servlet-class>
> >
> >     <init-param>
> >       <param-name>log4j-init-file</param-name>
> >       <param-value>WEB-INF/Log.cfg</param-value>
> >     </init-param>
> >
> >     <load-on-startup>1</load-on-startup>
> >   </servlet>
> > [...]
> >
> >
> > /webapp1/WEB-INF/Log.cfg
> > ------------------------
> > log4j.rootLogger=3Derror, stdout
> >
> > log4j.appender.stdout=3Dorg.apache.log4j.ConsoleAppender
> > log4j.appender.stdout.layout=3Dorg.apache.log4j.PatternLayout
> > log4j.appender.stdout.layout.ConversionPattern=3D[%p] %d{DATE}
> > (webapp1:%c.%M():%L) "%m"%n
> >
> >
> > webapp1 classes and JSP:
> > ------------------------
> > [...]
> > private static Logger logger =3D Logger.getLogger("MyClass");
> > [...]
> > logger.debug("test");
> > [...]
> >
> >
> > The same for webapp2, except for its Log.cfg which contains the
> >   [%p] %d{DATE} (webapp2:%c.%M():%L) "%m"%n
> > pattern.
> >
> > I see only "webapp2" in catalina.out, even for webapp1 classes.
> > Any help would be appreciated.
> >
> > --
> > Julien ALLANOS
> > Silicomp-AQL
>
>
> Do you have log4j.jar in the WEB-INF/lib of both webapps?

No I didn't, I had it in shared/lib.

> And is your
> initializer doing anything other than just calling
> PropertyConfigurator.confgure()?

Yes. I've just taken the Log4jInit class example from Tomcat docs. I've removed
it (and the corresponding servlet) since log4j.properties seems to be
automatically read.

> I recommend renaming your config files to
> log4j.properties and placing them in WEB-INF/clases.  You will then get
> separated logging configuration for each webapp.

Done.

> Note that in order to use a single global log4j.jar and not have log4j.jar in
> WEB-INF/lib of each app and not have each app stomp on the others
> configuration, you would need to install a repository selector.  If you have
> no
> idea what that is, I suggest you go with my first suggestion for now and read
> up on the topic before attempting to use it.  BTW, Log4j-1.3 will make this
> much easier.
>
>
> Jake
>

Thanks for your advice, I've read about classloaders and repository selectors,
and it's much clearer now. For the moment, I've just placed log4j.jar in each
WEB-INF/lib directory and log4j.properties in each WEB-INF/classes, and it
works well. Thanks a lot!
-- 
Julien ALLANOS
Silicomp-AQL

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


Mime
View raw message