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 "Satyanarayana, CVCB" <cv...@tanning.com> on 2001/12/11 16:10:55 UTC

log4j configuration

Hi log4j gurus,
 
Is there anybody who can help me for the following:
 
1. I wrote a wrapper class which uses Log4J.Category to print the log
statements, but I am not able to find the way to print the caller(the class
and the method that calls my wrapper class for logging) information. Since
other applications use my wrapper class for logging instead of
log4j.category, is there anyway can I print the caller information.
 
2. I am using configuration file for log4j configuration, where I define
layout formats, appenders etc. During the deployment, somebody needs to edit
the configuration file to set properly the layouts and appenders, can I put
a place holders in the configuration file and those place holders can be
filled up by environment variables ??? This makes easy for the deployment
environment instead of editing the log4j configuration file.
 
3. Since I am using PropertyConfigurator to configure my log4j environment,
how would I use BufferedOutputStream instead of standard IOStream???
 
I would appreciate if somebody let me know the answers.
 
Thanks,
Satya

RE: log4j configuration

Posted by Thomas Tuft Muller <tt...@online.no>.
| 1. I wrote a wrapper class which uses Log4J.Category to print the log
| statements, but I am not able to find the way to print the
| caller(the class
| and the method that calls my wrapper class for logging) information. Since
| other applications use my wrapper class for logging instead of
| log4j.category, is there anyway can I print the caller information.

class Wrapper {

	private static Category log = Category.getRoot();
	private static String className = Wrapper.class.getName();

	public void debug( String msg ) {
		log.log( className, Priority.DEBUG, msg , null );
	}

	....

}

|
| 2. I am using configuration file for log4j configuration, where I define
| layout formats, appenders etc. During the deployment, somebody
| needs to edit
| the configuration file to set properly the layouts and appenders,
| can I put
| a place holders in the configuration file and those place holders can be
| filled up by environment variables ??? This makes easy for the deployment
| environment instead of editing the log4j configuration file.

Both PropertyConfigurator and DOMConfigurator supports simple interpolation
from the System properties. This means that you can insert your environment
variables with System.setProperty() before log4j is configured (e.g. via
the -D option), and access them in the xml/properties file with
${myproperty}.

|
| 3. Since I am using PropertyConfigurator to configure my log4j
| environment,
| how would I use BufferedOutputStream instead of standard IOStream???

No exactly sure what you mean here. Are you talking about redirecting the
standard streams? In that case, look at
<log4j-root>/contribs/JimMoore/LoggingOutputStream. IMPORTANT: read the
mail-files in that directory as well.

Hope this helps

--

Thomas



*************************************************************************
Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights reserved. 
Confidential. No liability whatsoever is accepted for any loss or damage 
suffered as a result of accessing this message or any attachments.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>