@Test public void logEventMDC() { MDC.put("username", "decebal2"); MDC.put("session", getUUID()); MDC.put("ip", "127.0.0.1"); auditor.audit(new AuditEvent("Login")); }
@SuppressWarnings("unchecked") public void audit(AuditEvent event) { initFromMDC(event); LoggingEvent loggingEvent = new LoggingEvent(log.getName(), log, Level.DEBUG, event.getAction(), null); loggingEvent.setProperty("username", event.getUsername()); loggingEvent.setProperty("session", event.getSession()); loggingEvent.setProperty("ip", event.getIp()); Enumeration<Appender> en = log.getAllAppenders(); while (en.hasMoreElements()) { en.nextElement().doAppend(loggingEvent); } }
Log4jAuditor implements Auditor { @SuppressWarnings("unchecked") public void audit(AuditEvent event) { initFromMDC(event); LoggingEvent loggingEvent = new LoggingEvent(log.getName(), log, Level.DEBUG, event.getAction(), null); loggingEvent.setProperty("username", event.getUsername()); loggingEvent.setProperty("session", event.getSession()); loggingEvent.setProperty("ip", event.getIp()); Enumeration<Appender> en = log.getAllAppenders(); while (en.hasMoreElements()) { en.nextElement().doAppend(loggingEvent); } } }
Log4jAuditor implements Auditor { @SuppressWarnings("unchecked") public void audit(AuditEvent event) { initFromMDC(event); LoggingEvent loggingEvent = new LoggingEvent(log.getName(), log, Level.DEBUG, event.getAction(), null); loggingEvent.setProperty("username", event.getUsername()); loggingEvent.setProperty("session", event.getSession()); loggingEvent.setProperty("ip", event.getIp()); Enumeration<Appender> en = log.getAllAppenders(); while (en.hasMoreElements()) { en.nextElement().doAppend(loggingEvent); } } Log4jAuditor();  Log4jAuditor(String loggerName); }
Log4jAuditor implements Auditor { @SuppressWarnings("unchecked") public void audit(AuditEvent event) { initFromMDC(event); LoggingEvent loggingEvent = new LoggingEvent(log.getName(), log, Level.DEBUG, event.getAction(), null); loggingEvent.setProperty("username", event.getUsername()); loggingEvent.setProperty("session", event.getSession()); loggingEvent.setProperty("ip", event.getIp()); Enumeration<Appender> en = log.getAllAppenders(); while (en.hasMoreElements()) { en.nextElement().doAppend(loggingEvent); } } Log4jAuditor();  Log4jAuditor(String loggerName); @SuppressWarnings("unchecked") void audit(AuditEvent event); }
Log4jAuditor implements Auditor { @SuppressWarnings("unchecked") public void audit(AuditEvent event) { initFromMDC(event); LoggingEvent loggingEvent = new LoggingEvent(log.getName(), log, Level.DEBUG, event.getAction(), null); loggingEvent.setProperty("username", event.getUsername()); loggingEvent.setProperty("session", event.getSession()); loggingEvent.setProperty("ip", event.getIp()); Enumeration<Appender> en = log.getAllAppenders(); while (en.hasMoreElements()) { en.nextElement().doAppend(loggingEvent); } } Log4jAuditor();  Log4jAuditor(String loggerName); @SuppressWarnings("unchecked") void audit(AuditEvent event);  }