use of org.apache.logging.log4j.Marker in project hive by apache.
the class LlapRoutingAppenderPurgePolicy method update.
@Override
public void update(String key, LogEvent event) {
Marker marker = event.getMarker();
if (marker != null && marker.getName() != null && marker.getName().equals(Log4jQueryCompleteMarker.EOF_MARKER)) {
LOGGER.debug("Received " + Log4jQueryCompleteMarker.EOF_MARKER + " for key. Attempting cleanup.");
keyComplete(key);
} else {
if (knownAppenders.add(key)) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Registered key: [" + key + "] on purgePolicyWithName=" + name + ", thisAddress=" + System.identityHashCode(this));
}
}
}
}
use of org.apache.logging.log4j.Marker in project logging-log4j2 by apache.
the class DefaultRouteScriptAppenderTest method logAndCheck.
private void logAndCheck() {
final Marker marker = MarkerManager.getMarker("HEXDUMP");
final Logger logger = loggerContextRule.getLogger(DefaultRouteScriptAppenderTest.class);
logger.error("Hello");
final ListAppender listAppender = getListAppender();
final List<LogEvent> list = listAppender.getEvents();
assertNotNull("No events generated", list);
assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size() == 1);
logger.error("World");
assertTrue("Incorrect number of events. Expected 2, got " + list.size(), list.size() == 2);
logger.error(marker, "DEADBEEF");
assertTrue("Incorrect number of events. Expected 3, got " + list.size(), list.size() == 3);
}
use of org.apache.logging.log4j.Marker in project logging-log4j2 by apache.
the class RoutesScriptAppenderTest method logAndCheck.
private void logAndCheck() {
final Marker marker = MarkerManager.getMarker("HEXDUMP");
final Logger logger = loggerContextRule.getLogger(RoutesScriptAppenderTest.class);
logger.error("Hello");
final ListAppender listAppender = getListAppender();
final List<LogEvent> list = listAppender.getEvents();
assertNotNull("No events generated", list);
assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size() == 1);
logger.error("World");
assertTrue("Incorrect number of events. Expected 2, got " + list.size(), list.size() == 2);
logger.error(marker, "DEADBEEF");
assertTrue("Incorrect number of events. Expected 3, got " + list.size(), list.size() == 3);
}
use of org.apache.logging.log4j.Marker in project logging-log4j2 by apache.
the class PatternLayoutComparisonBenchmark method createLog4j2Event.
private static LogEvent createLog4j2Event() {
final Marker marker = null;
final String fqcn = "com.mycom.myproject.mypackage.MyClass";
final Level level = Level.DEBUG;
final Message message = new SimpleMessage(STR);
final Throwable t = null;
final Map<String, String> mdc = null;
final ContextStack ndc = null;
final String threadName = null;
final StackTraceElement location = null;
final long timestamp = 12345678;
return //
Log4jLogEvent.newBuilder().setLoggerName(//
"name(ignored)").setMarker(//
marker).setLoggerFqcn(//
fqcn).setLevel(//
level).setMessage(//
message).setThrown(//
t).setContextMap(//
mdc).setContextStack(//
ndc).setThreadName(//
threadName).setSource(//
location).setTimeMillis(//
timestamp).build();
}
use of org.apache.logging.log4j.Marker in project logging-log4j2 by apache.
the class MarkerAttributeConverterTest method testConvert02.
@Test
public void testConvert02() {
Marker marker = MarkerManager.getMarker("anotherConvert02").setParents(MarkerManager.getMarker("finalConvert03"));
marker = MarkerManager.getMarker("testConvert02").setParents(marker);
final String converted = this.converter.convertToDatabaseColumn(marker);
assertNotNull("The converted value should not be null.", converted);
assertEquals("The converted value is not correct.", "testConvert02[ anotherConvert02[ finalConvert03 ] ]", converted);
final Marker reversed = this.converter.convertToEntityAttribute(converted);
assertNotNull("The reversed value should not be null.", reversed);
assertEquals("The reversed value is not correct.", "testConvert02", marker.getName());
final Marker[] parents = marker.getParents();
assertNotNull("The first parent should not be null.", parents);
assertNotNull("The first parent should not be null.", parents[0]);
assertEquals("The first parent is not correct.", "anotherConvert02", parents[0].getName());
assertNotNull("The second parent should not be null.", parents[0].getParents());
assertNotNull("The second parent should not be null.", parents[0].getParents()[0]);
assertEquals("The second parent is not correct.", "finalConvert03", parents[0].getParents()[0].getName());
}
Aggregations