Define a Category with a name "DEBUG".

Then use that in your code.
Define your own Appender, with PatternLayout too.

Use a config file (xml, or properties based) to load this up.


Example ConsoleAppender with patternlayout.
log4j.appender.DestinationP=org.apache.log4j.ConsoleAppender
log4j.appender.DestinationP.Target=System.out
log4j.appender.DestinationP.layout=org.apache.log4j.PatternLayout
log4j.appender.DestinationP.layout.ConversionPattern=%c%m%n


----- Original Message -----
From: "Rafal Kedziorski" <[EMAIL PROTECTED]>
To: "Log4j Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, October 17, 2001 2:18 PM
Subject: The best way?!


> Hallo,
>
> I want use log4j with EJB's and Servlets. For this I would define one
DEBUG
> class based on Log4j Category, which should contains the same methods like
> Log4j Category. e.g.
>
> // for servlets (the same for EJB's)
> public BaseServlet extends HttpServlet {
>      protected static DEBUG debug = new DEBUG();
>      ...
> }
>
>
> public class DEBUG {
>      ...
>
>      DEBUG() {
>          // initialize data
>      }
>
>
>      public final static void debug(String message) {
>          cat.debug(message);
>      }
>
>
>      public final static void info(String message) {
>          cat.info(message);
>      }
>
>
>      public final static void warn(String message) {
>          cat.warn(message);
>      }
> }
>
> DEBUG should be used by all classes and should load own PatternLayout. But
> if I call my debug in my log file I see DEBUG.java as caller.
>
> Waht is the best solution for this?
>
>
> Best Regards,
> Rafal



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

Reply via email to