logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sandro.r...@namics.com
Subject Re: log4j and J2EE problem
Date Tue, 07 Aug 2001 15:07:09 GMT

hi maarten
in my opinion you've forget to initialize your property-file
like:

public void init()
{
     // init logging-infrastructure
     String log4j   = getServletConfig().getInitParameter
("Log4jConfigFile");
     if (log4j != null)
     {
          PropertyConfigurator.configure(getServletContext().getRealPath
("/") + log4j);
     }
     else
     {
          System.err.println( getServletInfo() + ": Parameter
Log4jConfigFile not specified correctly in Web.xml!!" );
          // throw a RuntimeExeption!
          throw new SsoConfigException("Logging-Environement not set in
web.xml ...");
     }
}

it should work...

we use log4j in a bea-cluster (with web- and ejb-container) and it works
fine...

hope this helps
sandro



                                                                                         
                                                     
                    Maarten Coene                                                        
                                                     
                    <MacBelgium@Tou       To:     log4j-user@jakarta.apache.org       
                                                        
                    ghGuy.net>            cc:                                         
                                                        
                                          Subject:     log4j and J2EE problem            
                                                     
                    07.08.2001                                                           
                                                     
                    16:32                                                                
                                                     
                    Please respond                                                       
                                                     
                    to "LOG4J Users                                                      
                                                     
                    Mailing List"                                                        
                                                     
                                                                                         
                                                     
                                                                                         
                                                     




Hi,

I want to use Log4J in my J2EE application, but I cannot manage to get
started with it: even a simple logging to the system.out doesn't seem to
work :-(

This is how I tried to do it:
1. I've created following configuration file named log4j.properties

# Set root category priority to DEBUG and its only appender to the
system.out
log4j.rootCategory=DEBUG, stdout

#test
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

2. I've placed this file somewhere in the classpath so my J2EE application
can find it.
3. I've put this code in a servlet source file (just to test if it works)

public class MainServlet extends HttpServlet {

     private transient static Category cat =
Category.getInstance(MainServlet.class.getName());

     /** Perform first-call initialization for the MainServlet */
     public void init() {
         cat.info("Initializing MainServlet");
         ...
     }
}

When I deploy my application and the servlet got initialized, nothing is
written to my system.out by log4j (nor is anything written to the
system.err indicating some errors). Could someone tell me what I'm doing
wrong here?

thx
Maarten

--
Maarten Coene
Katholieke Universiteit Leuven
Dept. Computerwetenschappen             Tel: ++32 (0)16/32 78 25
Celestijnenlaan 200A
B-3001 Heverlee



---------------------------------------------------------------------
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


Mime
View raw message