LOG4J2-2579: don't normalize dynamic events
diff --git a/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/AbstractEventLogger.java b/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/AbstractEventLogger.java
index f027668..c6e5e0e 100644
--- a/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/AbstractEventLogger.java
+++ b/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/AbstractEventLogger.java
@@ -91,12 +91,11 @@
}
private void logEvent(String eventName, String catalogId, Map<String, String> attributes, AuditExceptionHandler exceptionHandler) {
- String eventId = NamingUtils.lowerFirst(eventName);
- Event event = catalogId == null ? catalogManager.getEvent(eventId) : catalogManager.getEvent(eventId, catalogId);
+ Event event = catalogId == null ? catalogManager.getEvent(eventName) : catalogManager.getEvent(eventName, catalogId);
if (event == null) {
- throw new AuditException("Unable to locate definition of audit event " + eventId);
+ throw new AuditException("Unable to locate definition of audit event " + eventName);
}
- logEvent(eventId, attributes, event, exceptionHandler);
+ logEvent(eventName, attributes, event, exceptionHandler);
}
protected abstract void logEvent(StructuredDataMessage message);
diff --git a/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/AuditLoggerTest.java b/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/AuditLoggerTest.java
index c038c98..d60cc1e 100644
--- a/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/AuditLoggerTest.java
+++ b/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/AuditLoggerTest.java
@@ -38,9 +38,7 @@
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
/**
*
@@ -96,16 +94,15 @@
properties.put("fromAccount", "111111");
properties.put("amount", "111.55");
try {
- auditLogger.logEvent("Transfer", properties);
+ auditLogger.logEvent("transfer", properties);
} catch (Exception ex) {
ex.printStackTrace();
fail();
}
List<String> msgs = app.getMessages();
assertNotNull("No messages", msgs);
- assertTrue("No messages", msgs.size() == 1);
+ assertEquals("No messages", 1, msgs.size());
String msg = msgs.get(0);
- assertTrue("Normalized event name", msg.contains("transfer@"));
assertTrue("No companyId", msg.contains("companyId=\"12345\""));
assertTrue("No ipAddress", msg.contains("ipAddress=\"127.0.0.1\""));
assertTrue("No toAccount", msg.contains("toAccount=\"123456\""));
@@ -135,7 +132,7 @@
Map<String, String> properties = new HashMap<String, String>();
properties.put("toAccount", "123456");
properties.put("amount", "111.55");
- auditLogger.logEvent("Transfer", properties);
+ auditLogger.logEvent("transfer", properties);
}
@Test