Problems using RollingFileAppender

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems using RollingFileAppender

Kristina Marasovic
Hello there,

I have encountered a problem using RollingFileAppender class on my SuSE Linux
PC - my log file "testLogging.log" (appender named "A1") cannot be created.

I have downloaded the latest version of Chainsaw - Chainsaw v2 which contains
the log4j-1.3alpha-7.jar package, and also included that jar package in the
CLASSPATH so that logging methods can find the needed classes.

When I run "TestLogging" program from the command line (created just for
testing a log message) using "log4j.properties" for configuring Log4j,
following message with reported error appear:

-------------------------------------------------------------------------
~/log4j_proba> java TestLogging
*** configurationOptionStr=log4j.properties
log4j:INFO Using URL [file:/users/kim/log4j_proba/log4j.properties] for
automatic log4j configuration of repository named [default].
...
log4j:INFO Returning existing logger [org.apache.log4j] in repository
[default].
Reported error: "Could not instantiate appender named "A1"."
** End of LogManager static initializer
-----------------------------------------------------------------------


Following are the contents of the files: "TestLogging.java" and
"log4j.properties".

I have also noticed that the path of the RollingFileAppender.class in the
log4j-1.3alpha-7.jar is
        org/apache/log4j/rolling/RollingFileAppender.class
while according to the API it must be a part of the org.apache.log4j package.
So when I replace org.apache.log4j package with org.apache.log4j.rolling in
"log4j.properties" there are no error reports, but still, no log file is
created. Any hint as to what I am doing wrong will be most welcome.


TestLogging.java:
---------------------------------------
import org.apache.log4j.*;
public class TestLogging {
    static Logger logger = Logger.getLogger(TestLogging.class.getName());

    public static void main(String args[]) {
        logger.debug("Start of main()");
        logger.info("Just testing a log message with priority set to INFO");
        logger.warn("Just testing a log message with priority set to WARN");
        logger.error("Just testing a log message with priority set to ERROR");
        logger.fatal("Just testing a log message with priority set to FATAL");
    }
}
---------------------------------------



log4j.properties:
-----------------------------------------
log4j.logger.TestLogging=ERROR, A1

log4j.appender.A1=org.apache.log4j.RollingFileAppender
log4j.appender.A1.File=testLogging.log
log4j.appender.A1.MaxFileSize=100KB
log4j.appender.A1.MaxBackupIndex=1
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-5p [%t]: %c - %m%n
-------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Problems using RollingFileAppender

carnold-3
log4j 1.3 introduced a new RolllingFileAppender (RFA) framework in  
the org.apache.log4j.rolling package that is significantly different  
than the previous RFA's in the org.apache.log4j package.  The new  
framework allows custom rollover triggering and naming policies and  
should be more robust that the previous implementation.

To support migration of existing log4j configurations, emulations of  
the previous RFA's have been added to the CVS HEAD after the last  
alpha release.  These emulations read the old configuration, create a  
new-style RFA and delegate logging request to it.  There are fairly  
new and we would appreciate any comments.


On May 12, 2005, at 7:50 AM, Kristina Marasovic wrote:

> Hello there,
>
> I have encountered a problem using RollingFileAppender class on my  
> SuSE Linux
> PC - my log file "testLogging.log" (appender named "A1") cannot be  
> created.
>
> I have downloaded the latest version of Chainsaw - Chainsaw v2  
> which contains
> the log4j-1.3alpha-7.jar package, and also included that jar  
> package in the
> CLASSPATH so that logging methods can find the needed classes.
>
> When I run "TestLogging" program from the command line (created  
> just for
> testing a log message) using "log4j.properties" for configuring Log4j,
> following message with reported error appear:
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]