Hi,

   Is there anyway that I could prevent the call to getInstance of Category
in every action class.
  So I can have instance of Category in base action class and every other
class would extend from it.
  public class baseAction extends Action {
        static Category cat =
Category.getInstance(loginAction.class.getName());}

  this way I can just use this cat instance in all other action class which
extends from this base...
  public class logonAction extends baseAction{
                and I can put cat.debug etc. here

  but the problem is that it would always print the base class name in the
log. 
  I was wondering if it is required to have Category as static bcoz
otherwise I could pass the instance name of every classs instance to it..
-puneet
    
        


I currently use Log4j with NDC enabled combined with struts.

Here is how I use it:

- Run PropertyConfigurator from a startup servlet
- import org.apache.log4j.Category in your code
- set reference to log4j in your code

public class loginAction extends Action {
    static Category cat = Category.getInstance(loginAction.class.getName());
....
...
.
.


and in the body just call it:
            if ( cat.isDebugEnabled() )
                cat.debug("Attempting login with session: " + sessionid);


I hope that helps.  I wish all products were as easy as log4j to integrate.

-Mark

----- Original Message -----
From: "Sundar @eSaravana" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 27, 2001 2:01 PM
Subject: Has any one used struts and log4j successfully?


> Has anyone used log4j with struts? I have used log4j before, but I am new
to
> struts. So, I am just looking for a short cut. If you have,could you
please
> send me some code fragments to start off.
>
> I would really appreciate it.
>
> Cheers.....!
> Sundar
>
>

Reply via email to