struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject Re: Best pratice for using Log4j, EJB, Struts, and WebLogic 6.1 together
Date Wed, 06 Feb 2002 10:14:38 GMT
Sorry, that I continue this line even though this is not a Struts issue.

There's more to think about within this setup. Log4J does not
include any transactions/synchronisation for the appenders (you would
have to implement your own to do so). Let's say: you want to log into
the same RFAppender from EJBs and from your WebApp. This, at least
theoretically, doesn't work (no file sync, see Log4J docs). 
A good approach might be writing an own Appender, that uses JDBC (using 
a text file) for file sync.
But what if you have a cluster on different physical machines and you
want to have a log file on each machine? 


From: Adam 
Subject: Re: Best pratice for using Log4j, EJB, Struts, and WebLogic 6.1 together 
Date: Tue, 05 Feb 2002 11:06:37 -0800 


You may want to think about the configuration thing.  You web app and 
your EJBs should be separate, as should your logging.

Another option is to proxy Log4J to the EJB layer, but that is more work 
than you want to do.

You can copy the same log file twice as part of your build script, which 
would seem to be the easest answer.  If they are almost-but-not-quite 
identical, use the ant filter tag while copying.

Singletons in the web application should really be application scope 
Beans.  They should be stateless to teh same degree as Servlet is 
stateless.  If this is not an option, consider flyweight instead (usally 
a better way of doing business than singleton).  In the EJB Layer, A 
singleton probably should be a stateless session bean that does not 
participate in the transaction. My guess is that you should mark it's 
transaction attribute as Supports, but you may want to look into this 
more.  Basically, you don't want the Singleton causing deadlock.  Again, 
the Flyweight pattern is a better way of doing business.  Most EJB 
containers will keep the static classes deployed in the Jar separate 
from the static classes deployed in the war file, so you won't have a 
true singleton anyway, unless you do it at the container level (like the 
lib directory of the servlet container, at least in tomcat land).

Eric Ma wrote:

>Environment: WebLogic 6.1 SP1, Struts 1.0.1, and Log4j 1.1.3.  Application is 
>deployed as a single .ear file in a single WebLogic instance.  log4j.jar is in the 
>EJB classloader's classpath, not the WebLogic classpath nor the web app's classloader

>Scenario:  I want to be able to use Log4j in JSP custom tag handlers, servlets 
>(Struts action classes to be exact) and EJB's.
>What I have done so far:  used a startup servlet to do Log4j configuration for 
>servlets logging.  The config file is under the web app's WEB/INF directory.  
>Separately, I used a factory class with static methods to configure Log4j for EJB 
>logging, and for this I have to use a replicate of the configuration file but outside

>the .ear file.  I use a RFAppender for logging output.
>What I want to achieve: configure Log4j once for the WebLogic instance, not for EJB's

>and servlets separately, and I want to put the configuration file in the .ear file, 
>not outside it.
>Other general questions: do you see any major problems with regard to threading, 
>singleton, and static classes in a EJB container environment?
>Any suggestion is greatly welcome.
>Eric Ma
>This e-mail may contain confidential and/or privileged information. If you are not 
>the intended recipient (or have received this e-mail in error) please notify the 
>sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or 
>distribution of the material in this e-mail is strictly forbidden.
>To unsubscribe, e-mail:   <>
>For additional commands, e-mail: <>

Keine verlorenen Lotto-Quittungen, keine vergessenen Gewinne mehr! 
Beim WEB.DE Lottoservice:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message