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 Jacob Kjome <ho...@visi.com> on 2005/12/08 05:23:32 UTC

Re: Unable to write logs out to FileAppenders or RollingFileAppenders

Where is log4j.jar and where do you put log4j.properties.  To be more 
specific, do you have log4j.jar in WEB-INF/lib with log4j.properties in 
WEB-INF/classes, or are they in some other location?  How is log4j 
configured?  Default configuration or manual?

Jake

At 01:28 PM 12/7/2005 +0000, you wrote:
 >Hi,
 >
 > I cannot seem to get any logging data written to file type appenders
 >(FileAppener and RollingFileAppender) and am hoping someone can point
 >out what I am doing wrong.
 >
 > I seem to be able to manage what is logged to stdout without any
 >problems. The files do get created, but nothing is ever written to
 >them.
 >
 > I am using Tomcat 5.5.9 with JDK 1.4.2.
 >
 > Any help would be appreciated.
 >
 > Thanks
 >robin
 >
 >log4j.properties
 >-----------------------------------------------------------------
 >### direct log messages to stdout ###
 >log4j.appender.stdout=org.apache.log4j.ConsoleAppender
 >log4j.appender.stdout.Target=System.out
 >log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
 >log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L 
- %m%n
 >
 >log4j.appender.A1=org.apache.log4j.FileAppender
 >log4j.appender.A1.File=robin.log
 >log4j.appender.A1.Append=true
 >log4j.appender.A1.ImmediateFlush=true
 >log4j.appender.A1.layout=org.apache.log4j.PatternLayout
 >log4j.appender.A1.layout.ConversionPattern=%-5p: %m%n
 >
 >log4j.appender.A2=org.apache.log4j.RollingFileAppender
 >log4j.appender.A2.File=robin_rolling.log
 >log4j.appender.A2.MaxFileSize=100KB
 >log4j.appender.A2.MaxBackupIndex=1
 >log4j.appender.A2.layout=org.apache.log4j.PatternLayout
 >log4j.appender.A2.layout.ConversionPattern=%p %t %c - %m%n
 >
 >log4j.rootLogger=warn, A2
 >
 >log4j.logger.com.ia=debug, A1
 >#log4j.logger.com.ia=debug, A2
 >
 >log4j.logger.org.hibernate=info, A2
 >-----------------------------------------------------------------
 >
 >My java class looks something like this:
 >
 >-----------------------------------------------------------------
 >package com.ia.actions;
 >
 >import org.apache.log4j.Logger;
 >/* other import statements */
 >
 >public class HomeAction extends Action {
 >
 >    private static Logger log = Logger.getLogger(HomeAction.class.getName());
 >
 >    public ActionForward foo() {
 >
 >        log.debug("This is a logging statement.");
 >
 >    }
 >}
 >-----------------------------------------------------------------
 >
 >---------------------------------------------------------------------
 >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
 >For additional commands, e-mail: log4j-user-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Unable to write logs out to FileAppenders or RollingFileAppenders

Posted by Jacob Kjome <ho...@visi.com>.
Quoting Robin Clarke <ju...@googlemail.com>:

> The location of the files are:
>
> WEB-INF/lib/log4j-1.2.9.jar
> WEB-INF/classes/log4j.properties
>
> What do you mean by "default configuration or manual"?

"default" configuration refers to the automatic configuration performed by Log4j
in a static initializer.  It looks for log4j.xml or log4j.properties in the
default package (uses log4j.xml in preference to log4j.properties).  "manual"
configuration is where your code manually calls [some
configurator].configure("[path/to/log4j/config/file]").

Can you try changing to use log4j.xml?  As I stated in the parens above,
log4j.xml is used in preference to log4j.properties.  So, if Log4j finds a
log4j.xml on the classpath, it will use it instead of your log4j.properties,
meaning that although you think your app is using one config file, it may be,
secretly, using another.  Note that Log4j-1.3 reports which config file it is
using in "default" configuration in System.out, ameliorating this "secrecy". 
If this still doesn't work for you, then at least we've narrowed the possible
causes by one.

Let us know how it works for you.

Jake

>
> robin
>
> > Where is log4j.jar and where do you put log4j.properties.  To be more
> > specific, do you have log4j.jar in WEB-INF/lib with log4j.properties in
> > WEB-INF/classes, or are they in some other location?  How is log4j
> > configured?  Default configuration or manual?
> >
> > Jake
> >
> > At 01:28 PM 12/7/2005 +0000, you wrote:
> >  >Hi,
> >  >
> >  > I cannot seem to get any logging data written to file type appenders
> >  >(FileAppener and RollingFileAppender) and am hoping someone can point
> >  >out what I am doing wrong.
> >  >
> >  > I seem to be able to manage what is logged to stdout without any
> >  >problems. The files do get created, but nothing is ever written to
> >  >them.
> >  >
> >  > I am using Tomcat 5.5.9 with JDK 1.4.2.
> >  >
> >  > Any help would be appreciated.
> >  >
> >  > Thanks
> >  >robin
> >  >
> >  >log4j.properties
> >  >-----------------------------------------------------------------
> >  >### direct log messages to stdout ###
> >  >log4j.appender.stdout=org.apache.log4j.ConsoleAppender
> >  >log4j.appender.stdout.Target=System.out
> >  >log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
> >  >log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L
> > - %m%n
> >  >
> >  >log4j.appender.A1=org.apache.log4j.FileAppender
> >  >log4j.appender.A1.File=robin.log
> >  >log4j.appender.A1.Append=true
> >  >log4j.appender.A1.ImmediateFlush=true
> >  >log4j.appender.A1.layout=org.apache.log4j.PatternLayout
> >  >log4j.appender.A1.layout.ConversionPattern=%-5p: %m%n
> >  >
> >  >log4j.appender.A2=org.apache.log4j.RollingFileAppender
> >  >log4j.appender.A2.File=robin_rolling.log
> >  >log4j.appender.A2.MaxFileSize=100KB
> >  >log4j.appender.A2.MaxBackupIndex=1
> >  >log4j.appender.A2.layout=org.apache.log4j.PatternLayout
> >  >log4j.appender.A2.layout.ConversionPattern=%p %t %c - %m%n
> >  >
> >  >log4j.rootLogger=warn, A2
> >  >
> >  >log4j.logger.com.ia=debug, A1
> >  >#log4j.logger.com.ia=debug, A2
> >  >
> >  >log4j.logger.org.hibernate=info, A2
> >  >-----------------------------------------------------------------
> >  >
> >  >My java class looks something like this:
> >  >
> >  >-----------------------------------------------------------------
> >  >package com.ia.actions;
> >  >
> >  >import org.apache.log4j.Logger;
> >  >/* other import statements */
> >  >
> >  >public class HomeAction extends Action {
> >  >
> >  >    private static Logger log =
> Logger.getLogger(HomeAction.class.getName());
> >  >
> >  >    public ActionForward foo() {
> >  >
> >  >        log.debug("This is a logging statement.");
> >  >
> >  >    }
> >  >}
> >  >-----------------------------------------------------------------
> >  >
> >  >---------------------------------------------------------------------
> >  >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >  >For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>




---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Unable to write logs out to FileAppenders or RollingFileAppenders

Posted by Robin Clarke <ju...@googlemail.com>.
The location of the files are:

WEB-INF/lib/log4j-1.2.9.jar
WEB-INF/classes/log4j.properties

What do you mean by "default configuration or manual"?

robin

> Where is log4j.jar and where do you put log4j.properties.  To be more
> specific, do you have log4j.jar in WEB-INF/lib with log4j.properties in
> WEB-INF/classes, or are they in some other location?  How is log4j
> configured?  Default configuration or manual?
>
> Jake
>
> At 01:28 PM 12/7/2005 +0000, you wrote:
>  >Hi,
>  >
>  > I cannot seem to get any logging data written to file type appenders
>  >(FileAppener and RollingFileAppender) and am hoping someone can point
>  >out what I am doing wrong.
>  >
>  > I seem to be able to manage what is logged to stdout without any
>  >problems. The files do get created, but nothing is ever written to
>  >them.
>  >
>  > I am using Tomcat 5.5.9 with JDK 1.4.2.
>  >
>  > Any help would be appreciated.
>  >
>  > Thanks
>  >robin
>  >
>  >log4j.properties
>  >-----------------------------------------------------------------
>  >### direct log messages to stdout ###
>  >log4j.appender.stdout=org.apache.log4j.ConsoleAppender
>  >log4j.appender.stdout.Target=System.out
>  >log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
>  >log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L
> - %m%n
>  >
>  >log4j.appender.A1=org.apache.log4j.FileAppender
>  >log4j.appender.A1.File=robin.log
>  >log4j.appender.A1.Append=true
>  >log4j.appender.A1.ImmediateFlush=true
>  >log4j.appender.A1.layout=org.apache.log4j.PatternLayout
>  >log4j.appender.A1.layout.ConversionPattern=%-5p: %m%n
>  >
>  >log4j.appender.A2=org.apache.log4j.RollingFileAppender
>  >log4j.appender.A2.File=robin_rolling.log
>  >log4j.appender.A2.MaxFileSize=100KB
>  >log4j.appender.A2.MaxBackupIndex=1
>  >log4j.appender.A2.layout=org.apache.log4j.PatternLayout
>  >log4j.appender.A2.layout.ConversionPattern=%p %t %c - %m%n
>  >
>  >log4j.rootLogger=warn, A2
>  >
>  >log4j.logger.com.ia=debug, A1
>  >#log4j.logger.com.ia=debug, A2
>  >
>  >log4j.logger.org.hibernate=info, A2
>  >-----------------------------------------------------------------
>  >
>  >My java class looks something like this:
>  >
>  >-----------------------------------------------------------------
>  >package com.ia.actions;
>  >
>  >import org.apache.log4j.Logger;
>  >/* other import statements */
>  >
>  >public class HomeAction extends Action {
>  >
>  >    private static Logger log = Logger.getLogger(HomeAction.class.getName());
>  >
>  >    public ActionForward foo() {
>  >
>  >        log.debug("This is a logging statement.");
>  >
>  >    }
>  >}
>  >-----------------------------------------------------------------
>  >
>  >---------------------------------------------------------------------
>  >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>  >For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org