Search in sources :

Example 16 with Marker

use of org.apache.logging.log4j.Marker in project logging-log4j2 by apache.

the class PatternLayoutBenchmark method createLogEvent.

private static LogEvent createLogEvent() {
    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();
}
Also used : SimpleMessage(org.apache.logging.log4j.message.SimpleMessage) Message(org.apache.logging.log4j.message.Message) SimpleMessage(org.apache.logging.log4j.message.SimpleMessage) Level(org.apache.logging.log4j.Level) Marker(org.apache.logging.log4j.Marker) ContextStack(org.apache.logging.log4j.ThreadContext.ContextStack)

Example 17 with Marker

use of org.apache.logging.log4j.Marker in project logging-log4j2 by apache.

the class GelfLayoutBenchmark method createLogEvent.

private static LogEvent createLogEvent() {
    final Marker marker = null;
    final String fqcn = "com.mycom.myproject.mypackage.MyClass";
    final org.apache.logging.log4j.Level level = org.apache.logging.log4j.Level.DEBUG;
    final Message message = new SimpleMessage(MESSAGE);
    final Throwable t = null;
    final Map<String, String> mdc = null;
    final ThreadContext.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();
}
Also used : SimpleMessage(org.apache.logging.log4j.message.SimpleMessage) Message(org.apache.logging.log4j.message.Message) SimpleMessage(org.apache.logging.log4j.message.SimpleMessage) ThreadContext(org.apache.logging.log4j.ThreadContext) Marker(org.apache.logging.log4j.Marker)

Example 18 with Marker

use of org.apache.logging.log4j.Marker in project logging-log4j2 by apache.

the class MarkerTest method testRemoveNullMarker.

@Test
public void testRemoveNullMarker() {
    final String childMakerName = CHILD_MAKER_NAME + "-CM";
    final String parentMakerName = PARENT_MARKER_NAME + "-CM";
    final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMakerName);
    final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMakerName);
    slf4jMarker.add(slf4jParent);
    final Marker log4jParent = MarkerManager.getMarker(parentMakerName);
    final Marker log4jMarker = MarkerManager.getMarker(childMakerName);
    final Log4jMarker log4jSlf4jParent = new Log4jMarker(log4jParent);
    final Log4jMarker log4jSlf4jMarker = new Log4jMarker(log4jMarker);
    final org.slf4j.Marker nullMarker = null;
    Assert.assertFalse(log4jSlf4jParent.remove(nullMarker));
    Assert.assertFalse(log4jSlf4jMarker.remove(nullMarker));
}
Also used : Marker(org.apache.logging.log4j.Marker) Test(org.junit.Test)

Example 19 with Marker

use of org.apache.logging.log4j.Marker in project logging-log4j2 by apache.

the class MarkerTest method testContainsNullString.

@Test
public void testContainsNullString() {
    final String childMarkerName = CHILD_MAKER_NAME + "-CS";
    final String parentMakerName = PARENT_MARKER_NAME + "-CS";
    final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMarkerName);
    final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMakerName);
    slf4jMarker.add(slf4jParent);
    final Marker log4jParent = MarkerManager.getMarker(parentMakerName);
    final Marker log4jMarker = MarkerManager.getMarker(childMarkerName);
    final Log4jMarker log4jSlf4jParent = new Log4jMarker(log4jParent);
    final Log4jMarker log4jSlf4jMarker = new Log4jMarker(log4jMarker);
    final String nullStr = null;
    Assert.assertFalse(log4jSlf4jParent.contains(nullStr));
    Assert.assertFalse(log4jSlf4jMarker.contains(nullStr));
}
Also used : Marker(org.apache.logging.log4j.Marker) Test(org.junit.Test)

Example 20 with Marker

use of org.apache.logging.log4j.Marker in project logging-log4j2 by apache.

the class MarkerTest method testEquals.

@Test
public void testEquals() {
    final String childMarkerName = CHILD_MAKER_NAME + "-ASM";
    final String parentMakerName = PARENT_MARKER_NAME + "-ASM";
    final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMarkerName);
    final org.slf4j.Marker slf4jMarker2 = org.slf4j.MarkerFactory.getMarker(childMarkerName);
    final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMakerName);
    slf4jMarker.add(slf4jParent);
    final Marker log4jParent = MarkerManager.getMarker(parentMakerName);
    final Marker log4jMarker = MarkerManager.getMarker(childMarkerName);
    final Marker log4jMarker2 = MarkerManager.getMarker(childMarkerName);
    assertEquals(log4jParent, log4jParent);
    assertEquals(log4jMarker, log4jMarker);
    assertEquals(log4jMarker, log4jMarker2);
    assertEquals(slf4jMarker, slf4jMarker2);
    assertNotEquals(log4jParent, log4jMarker);
    assertNotEquals(log4jMarker, log4jParent);
}
Also used : Marker(org.apache.logging.log4j.Marker) Test(org.junit.Test)

Aggregations

Marker (org.apache.logging.log4j.Marker)50 Test (org.junit.Test)30 Message (org.apache.logging.log4j.message.Message)23 SimpleMessage (org.apache.logging.log4j.message.SimpleMessage)22 Level (org.apache.logging.log4j.Level)18 LogEvent (org.apache.logging.log4j.core.LogEvent)16 ContextStack (org.apache.logging.log4j.ThreadContext.ContextStack)14 Log4jLogEvent (org.apache.logging.log4j.core.impl.Log4jLogEvent)8 ObjectMessage (org.apache.logging.log4j.message.ObjectMessage)6 ReusableMessage (org.apache.logging.log4j.message.ReusableMessage)6 IOException (java.io.IOException)5 ClockFactoryTest (org.apache.logging.log4j.core.util.ClockFactoryTest)5 ReusableObjectMessage (org.apache.logging.log4j.message.ReusableObjectMessage)5 MutableThreadContextStack (org.apache.logging.log4j.spi.MutableThreadContextStack)5 StringMap (org.apache.logging.log4j.util.StringMap)5 ThreadContext (org.apache.logging.log4j.ThreadContext)4 Logger (org.apache.logging.log4j.core.Logger)4 ListAppender (org.apache.logging.log4j.test.appender.ListAppender)4 HashMap (java.util.HashMap)3 ThrowableProxy (org.apache.logging.log4j.core.impl.ThrowableProxy)3