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 Fred McCann <fr...@automaticrootbeer.com> on 2005/03/02 03:38:14 UTC
Setting parameters on custom loggers with setters
I'm writing some custom appenders and I'm trying to set parameters by
using setters.
public void setHashingMethod(String m) {
String hashMethod = m.toLowerCase();
if (hashMethod.equals("location"))
_hashMethod = HashUtility.LOCATION;
else if (hashMethod.equals("content"))
_hashMethod = HashUtility.CONTENT;
else if (hashMethod.equals("throwable"))
_hashMethod = HashUtility.THROWABLE;
else {
getErrorHandler().error("Invalid hash method: "+m+" for
logger "+getClass().getName());
close();
}
}
========================================
Here's what I'm using in my properties file:
log4j.rootLogger=DEBUG, A2
log4j.appender.A2=net.codesmarts.log4j.FileSystemBugReportAppender
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.thresholdPriority=ERROR
log4j.appender.A2.hashingMethod=location
log4j.appender.A2.directory=/Users/bman/Desktop/bugs
log4j.appender.A2.extension=.txt
# Print the date in ISO 8601 format
log4j.appender.A2.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
========================================
The only setter that isn't being called is setHashingMethod. I get this
message
when I try to use this appender:
log4j:WARN Failed to set property [hashingMethod] to value "location".
I'm just lost on this one. What does this message mean? Why would I get
it?
-- Fred McCann
fred@automaticrootbeer.com
Re: Setting parameters on custom loggers with setters
Posted by James Stauffer <st...@gmail.com>.
On Tue, 01 Mar 2005 21:38:14 -0500, Fred McCann
<fr...@automaticrootbeer.com> wrote:
> I'm writing some custom appenders and I'm trying to set parameters by
> using setters.
Here is an example that works for me:
public String getMdcKeys() {
return mdcKeys;
}
/**
* @param mdcKeys Comma separated list of MDC keys to include
*/
public void setMdcKeys(String mdcKeys) {
this.mdcKeys = mdcKeys;
}
private String mdcKeys;
In log4j.xml:
<param name="MdcKeys"
value="DateTime,username,docId,senderId,receiverId,formId,evisionDocId,engineKey,appKey1,FEDS,entry,entryParams,run,SNAL_Log,client,server,SQL-Query,SQL-Values,SQL-Elapsed,SQL-Rows,Exception"
/>
--
James Stauffer
http://www.geocities.com/stauffer_james/
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org