@Override protected void append(ILoggingEvent p) { if (!enable || eventWriter == null || !eventWriter.isEnable()) { return; } Level logLevel = p.getLevel(); if (logLevel.toInt() < minimumLevel) { return; } RecordEventSummary eventInfo = new RecordEventSummary(-1); eventInfo.setEventType(eventType); eventInfo.setThreadName(p.getThreadName()); eventInfo.setEventDate(new Date(p.getTimeStamp())); eventInfo.setEventClassName(p.getLoggerName()); eventInfo.setEventMethodName(logLevel.toString().toLowerCase()); // use message instead of formattedMessage for header!! // => use "... {0} .. {1} .." to compress event summary encoding eventInfo.setEventMethodDetail(p.getMessage()); if (!eventWriter.isEnable(eventInfo)) { return; } LogbackEventData eventData = new LogbackEventData(); eventData.setLevel(eventInfo, logLevel.toString()); eventData.setFormattedMessage(p.getFormattedMessage()); eventData.setArgumentArray(p.getArgumentArray()); if (p.getThrowableProxy() != null) { IThrowableProxy throwableProxy = p.getThrowableProxy(); // throwableProxy.getClassName() // throwableProxy.getMessage() StackTraceElementProxy[] traceElts = throwableProxy.getStackTraceElementProxyArray(); eventData.setStackTraceElements(traceElts); } Map<String, String> mdcPropertyMap = p.getMDCPropertyMap(); if (mdcPropertyMap != null && !mdcPropertyMap.isEmpty()) { eventData.setMDCPropertyMap(mdcPropertyMap); } eventWriter.addEvent(eventInfo, eventData, null); }
private Throwable getThrowable(ILoggingEvent logEvent) { if (logEvent.getThrowableProxy() instanceof ThrowableProxy) { return ((ThrowableProxy) logEvent.getThrowableProxy()).getThrowable(); } Object[] args = logEvent.getArgumentArray(); if (args == null || args.length == 0) { return null; } Object lastObject = args[args.length - 1]; if (lastObject instanceof Throwable) { return (Throwable) lastObject; } return null; }