dcsimg
log4j and tomcat 3.2.3
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   A_T
Posted On:   Tuesday, January 21, 2003 10:08 AM

I have configured log4j with tomcat but when I try to call logger.xxx(message) the output I get is does not show the classname or the line number. Here is my log4j.properties file #### Use two appenders, one to log to console, another to log to a file log4j.rootLogger=DEBUG, stdout, R # Print only messages of priority WARN or higher for your category #log4j.category.your.category.name=WARN # Specifically inherit the priority level #log4j.category.your.category.name=INHERITED #### First appender writes to console log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout # Pattern to output the call   More>>

I have configured log4j with tomcat but when I try to call logger.xxx(message) the output I get is does not show the classname or the line number. Here is my log4j.properties file

			
#### Use two appenders, one to log to console, another to log to a file
log4j.rootLogger=DEBUG, stdout, R

# Print only messages of priority WARN or higher for your category
#log4j.category.your.category.name=WARN
# Specifically inherit the priority level
#log4j.category.your.category.name=INHERITED

#### First appender writes to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
# i.e.
log4j.appender.stdout.layout.ConversionPattern=%5p (%F:%L) - %m%n

#### Second appender writes to a file
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${tomcat.home}/logs/phoenix.log

# Control the maximum log file size
log4j.appender.R.MaxFileSize=100KB
# Archive log files (one backup file here)
log4j.appender.R.MaxBackupIndex=1

log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p (%F:%L) - %m%n

#### test appender writes to a file
log4j.appender.test=org.apache.log4j.RollingFileAppender
log4j.appender.test.File=${tomcat.home}/logs/test.log

#### Default package priority
#log4j.logger.UserMsgs.MsgScreen=WARN, test
log4j.logger.com.mycom.CallingThread=DEBUG


here is a snippet of how I use the logger:

			
package com.mycom;

public class CallingThread extends Thread{
private static Logger logger = Logger.getLogger(CallingThread.class.getName());
// I have also tried Logger.getName("com.mycom.CallingThread");
// I have also tried Logger.getRootLogger();

public void run(){
Timer timer = new Timer();
TimerTask myTask = new TimerTask()}

public void run(){
logger.info("info");
logger.warn("warn");
}
}
timer.scheduleAtFixedRate(myTask, 0, 5000)
}
}


My servlet that runs this thread:

			
public class MyServlet extends HttpServlet{
CallingThread runner = new CallingThread();
public void init() throws ServletException{
runner.start();
}
}



When I start tomcat my log output is this:

			
INFO (?:?) - info
WARN (?:?) - warn


I was hoping someone out there could help me figure out why my output is not working right

   <<Less

Re: log4j and tomcat 3.2.3

Posted By:   Benoit_Quintin  
Posted On:   Tuesday, January 21, 2003 12:51 PM

Have you tried Logger.getLogger(getClass()) instead of getClass().getName() ??
About | Sitemap | Contact