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

Reply via email to