[slf4j-user] Per Web App logging

Ceki Gülcü listid at qos.ch
Mon Nov 20 23:21:17 CET 2006



In the MyWebAppContextListener  code you supplied, one can read:

  Log4JContextualRepositorySelector.addToRepository(pConfigFilePath);

How is the addToRepository method defined?

At 11:14 PM 11/20/2006, you wrote:
>Yes it is and all we did was to rename the MyRepositorySelector class that
>JBoss Wiki has. The code is the same as on
>http://wiki.jboss.org/wiki/Wiki.jsp?page=Log4jRepositorySelector
>
>Amir
>
>-----Original Message-----
>From: user-bounces at slf4j.org [mailto:user-bounces at slf4j.org] On Behalf Of
>Ceki Gülcü
>Sent: Monday, November 20, 2006 4:51 PM
>To: User list for the slf4j project
>Subject: Re: [slf4j-user] Per Web App logging
>
>
>Hi Amir,
>
>Is the Log4JContextualRepositorySelector class yours?
>
>At 09:55 PM 11/20/2006, you wrote:
> >Hi Ceki
> >
> >Thanks for the quick reply.
> >Here are my answers:
> >
> > >If you use the JNDI-based repository selector, you can place a single
> > >log4j.jar in the containers shared class loader. I am a little surprised
> > >that you need to copy log4j.jar in each web-app. Can you please
>elaborate?
> >
> >Here is the URL we used to configure the RepositorySelector.
> >http://wiki.jboss.org/wiki/Wiki.jsp?page=Log4jRepositorySelector
> >We have about 10 web apps running on JBoss AS and the above solution works.
> >Each web app has its own WEB-INF/lib/log4j.jar and WEB-INF/log4j.xml...
> >Also, each application has a class that implements ServletContextListener.
> >
> >public final class MyWebAppContextListener implements
>ServletContextListener
> >{
> >
> >     private ServletContext context = null;
> >     // we cannot use Logger.getLogger until we initialize it...
> >     private static Logger  log;
> >
> >...
> >...
> >...
> >
> >In this class we call (in contextInitialized() method):
> >
> >         this.context.log("Initializing Log4J...");
> >         // Before using Log4J logging system, we must initialize it by
> >adding
> >         // the webapp specific configuration to the repository.
> >
>Log4JContextualRepositorySelector.addToRepository(pConfigFilePath);
> >         // note that we can't call Logger.getLogger() until
> >         // Log4JContextualRepositorySelector.addToRepository() is called.
> >         // For all other classes in the webapp, you can call
> >Logger.getLogger()
> >         // at any time.
> >         log = Logger.getLogger(FindADocContextListener.class);
> >
> >That is it....
> >However this fails if we remove log4j.jar from WEB-INF/lib...
> >
> >
> >I do apologize if this question is gettting off topic
> >
> >Amir
> >
> >
> >
> >
> >
> >
> >
> >-----Original Message-----
> >From: user-bounces at slf4j.org [mailto:user-bounces at slf4j.org] On Behalf Of
> >Ceki Gülcü
> >Sent: Monday, November 20, 2006 3:43 PM
> >To: User list for the slf4j project
> >Subject: Re: [slf4j-user] Per Web App logging
> >
> >Hi Amir,
> >
> >At 09:32 PM 11/20/2006, Amir Mistric wrote:
> > >Hello Everyone
> > >
> > >My company would like to try SLF4J as a replacement for Log4J.
> > >Currently we use JBoss AS 4.x and the problem we had was that we could
>not
> > >configure logging "per web application".
> > >We ended up using RepositorySelector trick in order to be able to have a
> > >separate log4j.xml in every web application deployed.
> > >This approach, however, requires each web app to have a copy of log4j.jar
> > >in its WEB-INF/lib......
> >
> >If you use the JNDI-based repository selector, you can place a single
> >log4j.jar in the containers shared class loader. I am a little surprised
> >that you need to copy log4j.jar in each web-app. Can you please elaborate?
> >
> > >Recently we decided to create a shared library repository for all web
>apps
> > >we have.
> > >While this approach has reduced the "baggage" each web app had in its
> > >WEB-INF/lib we still have to use log4j.jar ....
> > >
> > >Our goal is simple. Have every web application running on the same app
> > >server have its own logging config file but share the single JAR (or
>jars).
> >
> >Not yet, but it's core feature planned in one of the next releases of
> >logback.
> >
> > >Can SLF4J accomplish this (using built in logback classic) for us?
> >
> >No, SLF4J is just a front for logback/jul/log4j/jcl. While SLF4J cannot
> >accomplish what you are asking, log4j can do so, and logback will in the
> >near future.
> >
> > >Thanks
> > >Amir
> >
> >--
> >Ceki Gülcü
> >Logback: The reliable, generic, fast and flexible logging framework for
> >Java.
> >http://logback.qos.ch
> >
> >_______________________________________________
> >user mailing list
> >user at slf4j.org
> >http://www.slf4j.org/mailman/listinfo/user
> >
> >_______________________________________________
> >user mailing list
> >user at slf4j.org
> >http://www.slf4j.org/mailman/listinfo/user
>
>--
>Ceki Gülcü
>Logback: The reliable, generic, fast and flexible logging framework for
>Java.
>http://logback.qos.ch
>
>_______________________________________________
>user mailing list
>user at slf4j.org
>http://www.slf4j.org/mailman/listinfo/user
>
>_______________________________________________
>user mailing list
>user at slf4j.org
>http://www.slf4j.org/mailman/listinfo/user

-- 
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch




More information about the slf4j-user mailing list