Hi there,
what's the recommended strategy for someone releasing a class
library which assumes a certain Log4j configuration? I'm assuming
reading the configuration file should be done only once and in the
main program, not in a class library.
Background is that in the Log4perl world, people are
I am using Log4j for the first time. How do I set up a property file (correctly) so I
only log to a file and not to the console? I only want messages at level INFO or
higher in my log file. This is what I tried. It didn't work:
log4j.rootLogger = INFO
log4j.DamlBuilder=INFO, FILE
log4j.rootLogger=INFO,FILE
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=./log.txt
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.conversionPattern=%p -%m%n
Will create a file named log.txt in the current working directory (the
Steven,
Thanks. This works, but I still get output to the screen (standard out?) as well. Is
there a way to prevent this?
Neil
-Original Message-
From: Ebersole, Steven [mailto:[EMAIL PROTECTED]
Sent: Friday, July 11, 2003 12:07 PM
To: 'Log4J Users List'
Subject: RE: Newbie Question
You should not be. In what type of environment is this running? In Tomcat?
In an app-server?
-Original Message-
From: Hainer, Neil [mailto:[EMAIL PROTECTED]
Sent: Friday, July 11, 2003 11:11 AM
To: Log4J Users List
Subject: RE: Newbie Question
Steven,
Thanks. This works, but I
Standalone. Just part of a java app.
-Original Message-
From: Ebersole, Steven [mailto:[EMAIL PROTECTED]
Sent: Friday, July 11, 2003 12:20 PM
To: 'Log4J Users List'
Subject: RE: Newbie Question
You should not be. In what type of environment is this running? In Tomcat?
In an
How are you doing the initialization of log4j?
Are you possibly using jakarta-commons-logging or using something that uses
it?
-Original Message-
From: Hainer, Neil [mailto:[EMAIL PROTECTED]
Sent: Friday, July 11, 2003 11:21 AM
To: Log4J Users List
Subject: RE: Newbie Question
I initialize it with the following line of code:
private static Logger logger = Logger.getLogger( DamlBuilder.class );
The only other line is:
logger.info( Input file: + getInputFileName() + two_spaces +
Output file: + getOutputFileName() + two_spaces +
You say just part of a java app... Some other part of that app must be
doing something with log4j. Try the code in your last message in a simple
main method using the property file; something like:
public class Tester
{
private static Logger logger = Logger.getLogger( Tester.class );
Sorry, bad copy and paste job. The property file should actually look like:
log4j.rootLogger=INFO
log4j.logger.DamlBuilder=INFO,FILE
log4j.additivity.DamlBuilder=false
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=./log.txt
I have extended Logger and LoggerFactory so that I can pass few params
such as hostname.
-Extended LoggerFactory-
public NtLoggerFactory(String appId, String hostName) {
this.appId = appId;
this.hostName = hostName;
}
public Logger
11 matches
Mail list logo