@SuppressWarnings("deprecation") static void assertEqualLogEvents(final LogEvent expected, final LogEvent actual, final boolean includeSource, final boolean includeContext, final boolean includeStacktrace) { assertEquals(expected.getClass(), actual.getClass()); assertEquals(includeContext ? expected.getContextData() : ContextDataFactory.createContextData(), actual.getContextData()); assertEquals(includeContext ? expected.getContextMap() : Collections.EMPTY_MAP, actual.getContextMap()); assertEquals(expected.getContextStack(), actual.getContextStack()); assertEquals(expected.getLevel(), actual.getLevel()); assertEquals(expected.getLoggerName(), actual.getLoggerName()); assertEquals(expected.getLoggerFqcn(), actual.getLoggerFqcn()); assertEquals(expected.getMarker(), actual.getMarker()); assertEquals(expected.getMessage(), actual.getMessage()); assertEquals(expected.getTimeMillis(), actual.getTimeMillis()); assertEquals(includeSource ? expected.getSource() : null, actual.getSource()); assertEquals(expected.getThreadName(), actual.getThreadName()); assertNotNull("original should have an exception", expected.getThrown()); assertNull("exception should not be serialized", actual.getThrown()); if (includeStacktrace) { // TODO should compare the rest of the ThrowableProxy assertEquals(expected.getThrownProxy(), actual.getThrownProxy()); } assertEquals(expected.isEndOfBatch(), actual.isEndOfBatch()); assertEquals(expected.isIncludeLocation(), actual.isIncludeLocation()); // original: non-null thrown & null thrownProxy // deserialized: null thrown & non-null thrownProxy assertNotEquals(expected.hashCode(), actual.hashCode()); assertNotEquals(expected, actual); }
assertSame(contextStack, e2.getContextStack()); assertEquals(true, e2.isEndOfBatch()); assertEquals(true, e2.isIncludeLocation()); assertSame(Level.FATAL, e2.getLevel()); assertSame(fqcn, e2.getLoggerFqcn());
@Override public boolean locationInformationExists() { return event.isIncludeLocation(); }
assertSame(contextStack, event2.getContextStack()); assertEquals(true, event2.isEndOfBatch()); assertEquals(true, event2.isIncludeLocation()); assertSame(Level.FATAL, event2.getLevel()); assertSame(fqcn, event2.getLoggerFqcn());
/** * Indicates whether the source of the logging request is required downstream. Annotated * {@link Transient @Transient} so as to not be included in the persisted entity. * * @return whether the source of the logging request is required downstream. */ @Override @Transient public final boolean isIncludeLocation() { return this.getWrappedEvent().isIncludeLocation(); }
@Override public Map<String, String> getCustomParameters() { Map<String, String> metaData = new HashMap<String, String>(); metaData.put("SourceType", "Log4j"); addLogEventProperty("LoggerName", logEvent.getLoggerName(), metaData); addLogEventProperty("LoggingLevel", logEvent.getLevel() != null ? logEvent.getLevel().name() : null, metaData); addLogEventProperty("ThreadName", logEvent.getThreadName(), metaData); addLogEventProperty("TimeStamp", getFormattedDate(logEvent.getTimeMillis()), metaData); if (isException()) { addLogEventProperty("Logger Message", getMessage(), metaData); } if (logEvent.isIncludeLocation()) { StackTraceElement stackTraceElement = logEvent.getSource(); addLogEventProperty("ClassName", stackTraceElement.getClassName(), metaData); addLogEventProperty("FileName", stackTraceElement.getFileName(), metaData); addLogEventProperty("MethodName", stackTraceElement.getMethodName(), metaData); addLogEventProperty("LineNumber", String.valueOf(stackTraceElement.getLineNumber()), metaData); } for (Map.Entry<String, String> entry : logEvent.getContextMap().entrySet()) { addLogEventProperty(entry.getKey(), entry.getValue(), metaData); } // 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; }
this.source = event.isIncludeLocation() ? event.getSource() : null; this.threadId = event.getThreadId(); this.threadName = event.getThreadName(); this.threadPriority = event.getThreadPriority(); this.endOfBatch = event.isEndOfBatch(); this.includeLocation = event.isIncludeLocation(); this.nanoTime = event.getNanoTime(); setMessage(event.getMessage());
this.thrown = other.getThrown(); this.contextStack = other.getContextStack(); this.includeLocation = other.isIncludeLocation(); this.endOfBatch = other.isEndOfBatch(); this.nanoTime = other.getNanoTime();