@Override public Map<String, String> getCustomParameters() { Map<String, String> metaData = new HashMap<String, String>(); metaData.put("SourceType", "LOGBack"); addLogEventProperty("LoggerName", loggingEvent.getLoggerName(), metaData); addLogEventProperty("LoggingLevel", loggingEvent.getLevel() != null ? loggingEvent.getLevel().levelStr : null, metaData); addLogEventProperty("ThreadName", loggingEvent.getThreadName(), metaData); addLogEventProperty("TimeStamp", getFormattedDate(loggingEvent.getTimeStamp()), metaData); if (isException()) { addLogEventProperty("Logger Message", getMessage(), metaData); } for (Map.Entry<String, String> entry : loggingEvent.getMDCPropertyMap().entrySet()) { addLogEventProperty(entry.getKey(), entry.getValue(), metaData); } // TODO: No location info? // TODO: Username, domain and identity should be included as in .NET version. // TODO: Should check, seems that it is not included in Log4j2. return metaData; }
ApplicationInsightsLogEvent event = new ApplicationInsightsLogEvent(loggingEvent); assertEquals(expected, event.getNormalizedSeverityLevel());
/** * Appends the new event. * Catching exceptions and check if the appender has been started is not necessary * as it all taken care by the AppenderBase class. * * @param eventObject The event to append. */ @Override protected void append(ILoggingEvent eventObject) { if (!this.isStarted() || !this.isInitialized) { // TODO: trace not started or not initialized. return; } ApplicationInsightsLogEvent aiEvent = new ApplicationInsightsLogEvent(eventObject); this.logTelemetryClientProxy.sendEvent(aiEvent); }
@Override public Exception getException() { Exception exception = null; if (isException()) { Throwable throwable = ((ThrowableProxy)this.loggingEvent.getThrowableProxy()).getThrowable(); exception = throwable instanceof Exception ? (Exception) throwable : new Exception(throwable); } return exception; }
/** * Appends the new event. * Catching exceptions and check if the appender has been started is not necessary * as it all taken care by the AppenderBase class. * * @param eventObject The event to append. */ @Override protected void append(ILoggingEvent eventObject) { if (!this.isStarted() || !this.isInitialized) { // TODO: trace not started or not initialized. return; } ApplicationInsightsLogEvent aiEvent = new ApplicationInsightsLogEvent(eventObject); this.logTelemetryClientProxy.sendEvent(aiEvent); }
@Override public Exception getException() { Exception exception = null; if (isException()) { Throwable throwable = ((ThrowableProxy)this.loggingEvent.getThrowableProxy()).getThrowable(); exception = throwable instanceof Exception ? (Exception) throwable : new Exception(throwable); } return exception; }
@Override public Map<String, String> getCustomParameters() { Map<String, String> metaData = new HashMap<String, String>(); metaData.put("SourceType", "LOGBack"); addLogEventProperty("LoggerName", loggingEvent.getLoggerName(), metaData); addLogEventProperty("LoggingLevel", loggingEvent.getLevel() != null ? loggingEvent.getLevel().levelStr : null, metaData); addLogEventProperty("ThreadName", loggingEvent.getThreadName(), metaData); addLogEventProperty("TimeStamp", getFormattedDate(loggingEvent.getTimeStamp()), metaData); if (isException()) { addLogEventProperty("Logger Message", getMessage(), metaData); } for (Map.Entry<String, String> entry : loggingEvent.getMDCPropertyMap().entrySet()) { addLogEventProperty(entry.getKey(), entry.getValue(), metaData); } // TODO: No location info? // TODO: Username, domain and identity should be included as in .NET version. // TODO: Should check, seems that it is not included in Log4j2. return metaData; }