logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benjamin Russell Stocum" <bsto...@paychex.com>
Subject Re: A few questions - tips for easy debugging?
Date Mon, 25 Jun 2001 17:49:29 GMT
I am also new to log4j, but I believe I can answer some of your questions. If I
am wrong, someone correct me :)

First are you missing R from "log4j.rootCategory=debug, logfile" ?

Q1:  Answer:  are you working with servlets?  If so I thought it was required
that you reinitialize Tomcat because of the way a servlet JVM engine is set up.

Q2: ? anyone?

Q3: ...this means do we have to create static Category instances for each class
files which I want to debug?
Answer:  From looking at the "Short introduction to log4j", the "Configuration"
section, this would appear to be the case, you would need to define a "static
Category" for each class you want detailed debugging on.  What I mean by this is
that if class A uses class B.  And class B does not define a "static Category",
then all the messages will appear as if they belonged to class A?

-Ben Stocum

Ken'ichi Unnai wrote:

> Dear All,
> I'm new to log4j.
> I'm playing log4j-1.1.3 with simple HelloWorld servlet (on tomcat3.2.1)
> with Ant as compiling tool. My WEB-INF/classes/log4j.properties
> is something like this:
> ---------------
> log4j.rootCategory=debug, logfile
> log4j.appender.logfile=org.apache.log4j.RollingFileAppender
> log4j.appender.logfile.File=debug.log
> log4j.appender.R.MaxFileSize=100KB
> log4j.appender.R.MaxBackupIndex=1
> log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
> log4j.appender.logfile.layout.ConversionPattern=%d %5p [%t] (%F:%L) - %m%n
> ---------------
> I have a few questions:
> Q1. When I modify a bit of HelloWorld.java code, rebuild it, and reload it,
>     then following message appears:
> log4j:ERROR No appenders could be found for category (HelloWorld).
> log4j:ERROR Please initialize the log4j system properly.
> ...so I have to restart tomcat every time. Is there any tips to avoid
> this?
> Q2. When I delete log file, then I have to restart tomcat. Is there any
>     tips to automatically create log file without restarting tomcat?
> Q3. I wrote Debug.java file as my utility lib, something like this:
> ----------------
> package util;
> import org.apache.log4j.Category;
> import org.apache.log4j.PropertyConfigurator;
> public class Debug {
>     public static Category log = Category.getInstance(Debug.class.getName());
>     public static void initDebug(String prefix, String file) {
>         if (file != null) {
>             PropertyConfigurator.configure(prefix+file);
>         }
>         log.debug("Debug.initDebug("+prefix+file+")");
>     }
> }
> ----------------
> This class is initialized as Debug.initDebug(...) at servlet init() method.
> I think this is cool & useful because whenever I want to debug,
> then all I have to do is just call
> Debug.log.debug("debugging...");
> in any class file. This works, but I found this method doesn't enable me to
> identify package name.
> Yep it does make sense, I only create Category instance
> Category.getInstance(Debug.class.getName())
> ...this means do we have to create static Category instances
> for each class files which I want to debug? Any tips?
> Sorry for many questions, but I believe this should be informative
> tips for other forks.
> Best regards,
> Ken
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org

View raw message