Author: sdeboy
Date: Mon Jun 7 06:23:30 2010
New Revision: 952112
URL: http://svn.apache.org/viewvc?rev=952112&view=rev
Log:
LoggingEventFieldResolver will now first attempt a case-sensitive property name
match, and attempt a case-insensitive match if that first match fails..
Required an update in pom.xml for log4j to 1.2.16 in order to use
LoggingEvent.getProperties
Modified:
logging/log4j/companions/extras/trunk/pom.xml
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/spi/LoggingEventFieldResolver.java
Modified: logging/log4j/companions/extras/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/pom.xml?rev=952112&r1=952111&r2=952112&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/pom.xml (original)
+++ logging/log4j/companions/extras/trunk/pom.xml Mon Jun 7 06:23:30 2010
@@ -274,7 +274,7 @@
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
- <version>1.2.9</version>
+ <version>1.2.16</version>
</dependency>
</dependencies>
<reporting>
Modified:
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/spi/LoggingEventFieldResolver.java
URL:
http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/spi/LoggingEventFieldResolver.java?rev=952112&r1=952111&r2=952112&view=diff
==============================================================================
---
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/spi/LoggingEventFieldResolver.java
(original)
+++
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/spi/LoggingEventFieldResolver.java
Mon Jun 7 06:23:30 2010
@@ -18,7 +18,10 @@
package org.apache.log4j.spi;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.StringTokenizer;
import java.util.Locale;
@@ -227,6 +230,17 @@ public final class LoggingEventFieldReso
} else if (upperField.startsWith(PROP_FIELD)) {
//note: need to use actual fieldname since case matters
Object propValue = event.getMDC(fieldName.substring(5));
+ if (propValue == null) {
+ //case-specific match didn't work, try case insensitive match
+ String lowerPropKey = fieldName.substring(5).toLowerCase();
+ Set entrySet = event.getProperties().entrySet();
+ for (Iterator iter = entrySet.iterator();iter.hasNext();) {
+ Map.Entry thisEntry = (Map.Entry) iter.next();
+ if
(thisEntry.getKey().toString().toLowerCase().equals(lowerPropKey)) {
+ propValue = thisEntry.getValue();
+ }
+ }
+ }
return ((propValue == null) ? EMPTY_STRING : propValue.toString());
} else {
LocationInfo info = event.getLocationInformation();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]