Hi,

I thought that log4j was automatically configured if it found a file name 
log4j.properties somewhere in its classpath.
How do you log something in your Enterprise Beans using the log4j API? I 
guess you cannot access that servlet configuration file from there?

But I'll try it out...

Maarten

At 17:07 7/08/2001 +0200, you wrote:

>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: 
> [EMAIL PROTECTED] 
>
>                     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: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]

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



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

Reply via email to