LOG4J2-2428: reuse the AuditLogger to log events

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/commit/78b7c3f8
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/tree/78b7c3f8
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/diff/78b7c3f8

Branch: refs/heads/master
Commit: 78b7c3f8cda8ed167a7301b0592f48988757f07a
Parents: 06dbe88
Author: Andrei Ivanov <[email protected]>
Authored: Sun Sep 30 23:07:11 2018 +0300
Committer: Andrei Ivanov <[email protected]>
Committed: Sun Sep 30 23:07:11 2018 +0300

----------------------------------------------------------------------
 .../org/apache/logging/log4j/audit/LogEventFactory.java     | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/78b7c3f8/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/LogEventFactory.java
----------------------------------------------------------------------
diff --git 
a/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/LogEventFactory.java
 
b/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/LogEventFactory.java
index 8746209..ac43507 100644
--- 
a/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/LogEventFactory.java
+++ 
b/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/LogEventFactory.java
@@ -54,10 +54,9 @@ import static 
org.apache.logging.log4j.catalog.api.util.StringUtils.appendNewlin
 public class LogEventFactory {
 
     private static final Logger logger = 
LogManager.getLogger(LogEventFactory.class);
-    private static final String NAME = "AuditLogger";
-    private static final String FQCN = LogEventFactory.class.getName();
-    private static Marker EVENT_MARKER = 
MarkerManager.getMarker("Audit").addParents(EventLogger.EVENT_MARKER);
-    private static final ExtendedLogger LOGGER = 
LogManager.getContext(false).getLogger(NAME);
+
+    private static final AuditLogger AUDIT_LOGGER = new AuditLogger();
+
     private static final int DEFAULT_MAX_LENGTH = 32;
 
     private static final AuditExceptionHandler DEFAULT_HANDLER = (message, ex) 
-> {
@@ -171,7 +170,7 @@ public class LogEventFactory {
      */
     public static void logEvent(AuditMessage msg, AuditExceptionHandler 
handler) {
         try {
-            LOGGER.logIfEnabled(FQCN, Level.OFF, EVENT_MARKER, msg, null);
+               AUDIT_LOGGER.logEvent(msg);
         } catch (Throwable ex) {
             if (handler == null) {
                 handler = defaultExceptionHandler;

Reply via email to