class Log4jAuditor implements Auditor {

    @SuppressWarnings("unchecked")
    public void audit(AuditEvent event) {
        initFromMDC(event);

        // create the logging event from audit 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());

        // add the logging event to all appenders
        Enumeration<Appender> en = log.getAllAppenders();
        while (en.hasMoreElements()) {
            en.nextElement().doAppend(loggingEvent);
        }
    }

}

class Log4jAuditorTest {

    private Auditor auditor;

    @Test
    public void logEvent() {

        auditor.audit(new AuditEvent("Login").setUsername("decebal1").setSession(getUUID()).setIp("localhost"));
    }

}