Search in sources :

Example 31 with LoggingEvent

use of org.apache.log4j.spi.LoggingEvent in project flink by apache.

the class UtilsTest method checkForLogString.

public static void checkForLogString(String expected) {
    LoggingEvent found = getEventContainingString(expected);
    if (found != null) {
        LOG.info("Found expected string '" + expected + "' in log message " + found);
        return;
    }
    Assert.fail("Unable to find expected string '" + expected + "' in log messages");
}
Also used : LoggingEvent(org.apache.log4j.spi.LoggingEvent)

Example 32 with LoggingEvent

use of org.apache.log4j.spi.LoggingEvent in project hadoop by apache.

the class ContainerLogAppender method close.

@Override
public synchronized void close() {
    closing = true;
    if (tail != null) {
        for (LoggingEvent event : tail) {
            super.append(event);
        }
    }
    super.close();
}
Also used : LoggingEvent(org.apache.log4j.spi.LoggingEvent)

Example 33 with LoggingEvent

use of org.apache.log4j.spi.LoggingEvent in project neo4j by neo4j.

the class Slf4jLogProviderTest method assertLogOccurred.

private void assertLogOccurred(Level level, String message) {
    ArrayList<LoggingEvent> events = getLoggingEvents();
    assertThat(events, hasSize(1));
    LoggingEvent event = events.get(0);
    assertThat(event.getLoggerName(), is(getClass().getName()));
    assertThat(event.getLevel(), is(level));
    assertThat(event.getMessage(), is((Object) message));
}
Also used : LoggingEvent(org.apache.log4j.spi.LoggingEvent)

Example 34 with LoggingEvent

use of org.apache.log4j.spi.LoggingEvent in project intellij-community by JetBrains.

the class TestLoggerFactory method log.

static void log(@NotNull org.apache.log4j.Logger logger, @NotNull Level level, @Nullable String message, @Nullable Throwable t) {
    if (!UsefulTestCase.IS_UNDER_TEAMCITY) {
    //return;
    }
    LoggingEvent event = new LoggingEvent(CFQN, logger, level, message, t);
    APPENDER.doAppend(event);
    if (BUFFER.length() > MAX_BUFFER_LENGTH) {
        synchronized (BUFFER) {
            if (BUFFER.length() > MAX_BUFFER_LENGTH) {
                BUFFER.delete(0, BUFFER.length() - MAX_BUFFER_LENGTH + MAX_BUFFER_LENGTH / 4);
            }
        }
    }
}
Also used : LoggingEvent(org.apache.log4j.spi.LoggingEvent)

Example 35 with LoggingEvent

use of org.apache.log4j.spi.LoggingEvent in project intellij-plugins by JetBrains.

the class LightTestCase method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    ourShouldFail = false;
    Logger.getRootLogger().addAppender(new AppenderSkeleton() {

        @Override
        protected void append(LoggingEvent loggingEvent) {
            if (loggingEvent.level.isGreaterOrEqual(Priority.ERROR)) {
                ourShouldFail = true;
            }
        }

        @Override
        public boolean requiresLayout() {
            return false;
        }

        @Override
        public void close() {
        }
    });
}
Also used : LoggingEvent(org.apache.log4j.spi.LoggingEvent) AppenderSkeleton(org.apache.log4j.AppenderSkeleton)

Aggregations

LoggingEvent (org.apache.log4j.spi.LoggingEvent)48 Test (org.junit.Test)21 Logger (org.apache.log4j.Logger)12 Pattern (java.util.regex.Pattern)7 Matcher (java.util.regex.Matcher)6 ByteArrayOutputStream (org.apache.commons.io.output.ByteArrayOutputStream)6 AppenderSkeleton (org.apache.log4j.AppenderSkeleton)3 LoggingException (com.axway.ats.log.autodb.exceptions.LoggingException)2 AbstractLoggingEvent (com.axway.ats.log.autodb.model.AbstractLoggingEvent)2 IOException (java.io.IOException)2 Appender (org.apache.log4j.Appender)2 Category (org.apache.log4j.Category)2 Level (org.apache.log4j.Level)2 Filter (org.apache.log4j.spi.Filter)2 LocationInfo (org.apache.log4j.spi.LocationInfo)2 InsertMessageEvent (com.axway.ats.log.autodb.events.InsertMessageEvent)1 CacheableEvent (com.axway.ats.log.autodb.model.CacheableEvent)1 SystemLogLevel (com.axway.ats.log.model.SystemLogLevel)1 CurrentUser (com.google.gerrit.server.CurrentUser)1 IdentifiedUser (com.google.gerrit.server.IdentifiedUser)1