Search in sources :

Example 1 with LogEvent

use of org.apache.logging.log4j.core.LogEvent in project cas by apereo.

the class CloudWatchAppender method append.

@Override
public void append(final LogEvent logEvent) {
    final LogEvent event = LoggingUtils.prepareLogEvent(logEvent);
    final InputLogEvent awsLogEvent = new InputLogEvent();
    final long timestamp = event.getTimeMillis();
    final String message = new String(getLayout().toByteArray(event));
    awsLogEvent.setTimestamp(timestamp);
    awsLogEvent.setMessage(message);
    if (!queue.offer(awsLogEvent) && !queueFull) {
        queueFull = true;
    } else if (queueFull) {
        queueFull = false;
    }
}
Also used : LogEvent(org.apache.logging.log4j.core.LogEvent) InputLogEvent(com.amazonaws.services.logs.model.InputLogEvent) InputLogEvent(com.amazonaws.services.logs.model.InputLogEvent)

Example 2 with LogEvent

use of org.apache.logging.log4j.core.LogEvent in project spring-boot by spring-projects.

the class ExtendedWhitespaceThrowablePatternConverterTests method withStackTrace.

@Test
public void withStackTrace() throws Exception {
    LogEvent event = Log4jLogEvent.newBuilder().setThrown(new Exception()).build();
    StringBuilder builder = new StringBuilder();
    this.converter.format(event, builder);
    assertThat(builder).startsWith(LINE_SEPARATOR).endsWith(LINE_SEPARATOR);
}
Also used : Log4jLogEvent(org.apache.logging.log4j.core.impl.Log4jLogEvent) LogEvent(org.apache.logging.log4j.core.LogEvent) Test(org.junit.Test)

Example 3 with LogEvent

use of org.apache.logging.log4j.core.LogEvent in project spring-boot by spring-projects.

the class ExtendedWhitespaceThrowablePatternConverterTests method noStackTrace.

@Test
public void noStackTrace() throws Exception {
    LogEvent event = Log4jLogEvent.newBuilder().build();
    StringBuilder builder = new StringBuilder();
    this.converter.format(event, builder);
    assertThat(builder.toString()).isEqualTo("");
}
Also used : Log4jLogEvent(org.apache.logging.log4j.core.impl.Log4jLogEvent) LogEvent(org.apache.logging.log4j.core.LogEvent) Test(org.junit.Test)

Example 4 with LogEvent

use of org.apache.logging.log4j.core.LogEvent in project spring-boot by spring-projects.

the class WhitespaceThrowablePatternConverterTests method noStackTrace.

@Test
public void noStackTrace() throws Exception {
    LogEvent event = Log4jLogEvent.newBuilder().build();
    StringBuilder builder = new StringBuilder();
    this.converter.format(event, builder);
    assertThat(builder.toString()).isEqualTo("");
}
Also used : Log4jLogEvent(org.apache.logging.log4j.core.impl.Log4jLogEvent) LogEvent(org.apache.logging.log4j.core.LogEvent) Test(org.junit.Test)

Example 5 with LogEvent

use of org.apache.logging.log4j.core.LogEvent in project spring-boot by spring-projects.

the class WhitespaceThrowablePatternConverterTests method withStackTrace.

@Test
public void withStackTrace() throws Exception {
    LogEvent event = Log4jLogEvent.newBuilder().setThrown(new Exception()).build();
    StringBuilder builder = new StringBuilder();
    this.converter.format(event, builder);
    assertThat(builder.toString()).startsWith(LINE_SEPARATOR).endsWith(LINE_SEPARATOR);
}
Also used : Log4jLogEvent(org.apache.logging.log4j.core.impl.Log4jLogEvent) LogEvent(org.apache.logging.log4j.core.LogEvent) Test(org.junit.Test)

Aggregations

LogEvent (org.apache.logging.log4j.core.LogEvent)188 Test (org.junit.Test)150 Log4jLogEvent (org.apache.logging.log4j.core.impl.Log4jLogEvent)127 SimpleMessage (org.apache.logging.log4j.message.SimpleMessage)94 Message (org.apache.logging.log4j.message.Message)33 Marker (org.apache.logging.log4j.Marker)16 StructuredDataMessage (org.apache.logging.log4j.message.StructuredDataMessage)11 HashMap (java.util.HashMap)9 LoggerContext (org.apache.logging.log4j.core.LoggerContext)8 ClockFactoryTest (org.apache.logging.log4j.core.util.ClockFactoryTest)8 File (java.io.File)7 IOException (java.io.IOException)7 Level (org.apache.logging.log4j.Level)7 MapMessage (org.apache.logging.log4j.message.MapMessage)6 ContextStack (org.apache.logging.log4j.ThreadContext.ContextStack)5 Appender (org.apache.logging.log4j.core.Appender)5 ObjectMessage (org.apache.logging.log4j.message.ObjectMessage)5 ReusableMessage (org.apache.logging.log4j.message.ReusableMessage)5 ReusableObjectMessage (org.apache.logging.log4j.message.ReusableObjectMessage)5 ListAppender (org.apache.logging.log4j.test.appender.ListAppender)5