logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hainer, Neil" <hain...@jivanet.net>
Subject RE: Newbie Question
Date Sat, 12 Jul 2003 20:34:52 GMT
Steve,
 
I will give a try on Monday and let you know the results.
 
Thanks,
 
Neil

	-----Original Message----- 
	From: Ebersole, Steven [mailto:steven.ebersole@vignette.com] 
	Sent: Fri 7/11/2003 2:11 PM 
	To: 'Log4J Users List' 
	Cc: 
	Subject: RE: Newbie Question
	
	

	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
	log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
	log4j.appender.FILE.layout.conversionPattern=%p -%m%n
	
	
	
	
	-----Original Message-----
	From: Ebersole, Steven
	Sent: Friday, July 11, 2003 1:08 PM
	To: 'Log4J Users List'
	Subject: RE: Newbie Question
	
	
	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 );
	
	    public static void main( String[] args )
	    {
	        logger.info( "Testing" );
	    }
	}
	
	This will put a single log message into your log.txt file without it showing
	up on stdout.
	
	
	
	You can also slightly modify the properties file to subvert whatever else is
	playing with log4j...
	
	log4j.rootLogger=INFO
	log4j.DamlBuilder=INFO,FILE
	log4j.additivity.DamlBuilder=false
	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
	
	which basically tells lo4j to log messages sent to the logger named
	DamlBuilder _only_ to appenders explicitly attached to it, and not the
	appenders of loggers higher in its hierarchy.  This is assuming that the
	DamlBuilder class is not in a package; if it is, then make the changes in
	the above two lines to include its package name...
	
	
	
	-----Original Message-----
	From: Hainer, Neil [mailto:hainern@jivanet.net]
	Sent: Friday, July 11, 2003 11:30 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 +
	instances + " Object Instances Created" +
	                   two_spaces + QuickTimeFormat.msToSecs( pTime ) + "
	seconds." );
	
	-----Original Message-----
	From: Ebersole, Steven [mailto:steven.ebersole@vignette.com]
	Sent: Friday, July 11, 2003 12:25 PM
	To: 'Log4J Users List'
	Subject: RE: Newbie Question
	
	
	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:hainern@jivanet.net]
	Sent: Friday, July 11, 2003 11:21 AM
	To: Log4J Users List
	Subject: RE: Newbie Question
	
	
	Standalone.  Just part of a java app.
	
	-----Original Message-----
	From: Ebersole, Steven [mailto:steven.ebersole@vignette.com]
	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 app-server?
	
	
	
	-----Original Message-----
	From: Hainer, Neil [mailto:hainern@jivanet.net]
	Sent: Friday, July 11, 2003 11:11 AM
	To: Log4J Users List
	Subject: RE: Newbie Question
	
	
	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:steven.ebersole@vignette.com]
	Sent: Friday, July 11, 2003 12:07 PM
	To: 'Log4J Users List'
	Subject: RE: Newbie Question
	
	
	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
	directory from where the java process was started).
	
	
	
	-----Original Message-----
	From: Hainer, Neil [mailto:hainern@jivanet.net]
	Sent: Friday, July 11, 2003 11:02 AM
	To: log4j-user@jakarta.apache.org
	Subject: Newbie Question
	
	
	
	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.appender.CONSOLE=org.appache.log4j.ConsoleAppender
	
	#set the appender FILE
	log4j.appender.FILE=org.apache.log4j.FileAppender
	log4j.appender.FILE.File=.\log.txt
	
	#set the layout for the appenders
	#log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
	#log4j.appender.CONSOLE.layout.conversionPattern=%p -%m%n
	
	#set the layout for the appenders
	log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
	log4j.appender.FILE.layout.conversionPattern=%p -%m%n
	
	Thanks,
	
	Neil
	
	Neil Hainer
	Booz Allen & Hamilton
	JIVA System Integration Project
	703-289-3881
	
	
	---------------------------------------------------------------------
	To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
	For additional commands, e-mail: log4j-user-help@jakarta.apache.org
	
	---------------------------------------------------------------------
	To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
	For additional commands, e-mail: log4j-user-help@jakarta.apache.org
	
	
	---------------------------------------------------------------------
	To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
	For additional commands, e-mail: log4j-user-help@jakarta.apache.org
	
	---------------------------------------------------------------------
	To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
	For additional commands, e-mail: log4j-user-help@jakarta.apache.org
	
	
	---------------------------------------------------------------------
	To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
	For additional commands, e-mail: log4j-user-help@jakarta.apache.org
	
	---------------------------------------------------------------------
	To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
	For additional commands, e-mail: log4j-user-help@jakarta.apache.org
	
	
	---------------------------------------------------------------------
	To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
	For additional commands, e-mail: log4j-user-help@jakarta.apache.org
	
	---------------------------------------------------------------------
	To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
	For additional commands, e-mail: log4j-user-help@jakarta.apache.org
	
	---------------------------------------------------------------------
	To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
	For additional commands, e-mail: log4j-user-help@jakarta.apache.org
	
	

Mime
View raw message