You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Kevin Smolkowski <ke...@smolkowski.com> on 2005/01/12 07:09:02 UTC

I cannot get log4j to log to other than the tomcat console

I don't get any errors on startup, but I cannot get log4j to send my log 
messages
to a file.  No matter what I put in the properties file they get loaded 
to the console.

In my application.
1) I have an initialization servlet which loads the properties.  

public class Log4jInit extends HttpServlet {

  public
  void init() {
    String prefix =  getServletContext().getRealPath("/");
    String file = getInitParameter("log4j-init-file");

    // if the log4j-init-file is not set, then no point in trying
    if(file != null) {
      System.out.println("Configuring log4j using file " + prefix + file);
      PropertyConfigurator.configure(prefix+file);
    } else {
        System.out.println("Cannot find log4j init file");
    }
  }


2)  My servet loads fine, and I even get this message in my log file.  
So I know it is loading..

Configuring log4j using file 
/usr/local/tomcat/webapps/GarageView/WEB-INF/log4j.properties

3) My log4j.properties file has append to /var/tmp/garageview.log

log4j.catagory.GARAGEVIEW=DEBUG, GV
log4j.appender.GV=org.apache.log4j.RollingFileAppender
log4j.appender.GV.File=/var/tmp/garageview.log
log4j.appender.GV.MaxFileSize=10KB
log4j.appender.GV.MaxBackupIndex=1
log4j.appender.GV.layout=org.apache.log4j.PatternLayout
log4j.appender.GV.layout.ConversionPattern=%d - %m%n

4) But still, my messages so up in the console log.
0    [main] INFO  GV  - StampServlet Init
214  [main] INFO  GV  - Found port /dev/term/a