Search in sources :

Example 61 with Log

use of org.apache.commons.logging.Log in project contribution by checkstyle.

the class CommonsLoggingListener method fileFinished.

/**
 * @see com.puppycrawl.tools.checkstyle.api.AuditListener
 */
public void fileFinished(AuditEvent aEvt) {
    if (mInitialized) {
        final Log log = mLogFactory.getInstance(Checker.class);
        log.info("File \"" + aEvt.getFileName() + "\" finished.");
    }
}
Also used : Log(org.apache.commons.logging.Log)

Example 62 with Log

use of org.apache.commons.logging.Log in project contribution by checkstyle.

the class CommonsLoggingListener method auditFinished.

/**
 * @see com.puppycrawl.tools.checkstyle.api.AuditListener
 */
public void auditFinished(AuditEvent aEvt) {
    if (mInitialized) {
        final Log log = mLogFactory.getInstance(Checker.class);
        log.info("Audit finished.");
    }
}
Also used : Log(org.apache.commons.logging.Log)

Example 63 with Log

use of org.apache.commons.logging.Log in project logging-log4j2 by apache.

the class LoggerTest method testLog.

@Test
public void testLog() {
    final Log logger = LogFactory.getLog("LoggerTest");
    logger.debug("Test message");
    verify("List", "o.a.l.l.j.LoggerTest Test message MDC{}" + Strings.LINE_SEPARATOR);
    logger.debug("Exception: ", new NullPointerException("Test"));
    verify("List", "o.a.l.l.j.LoggerTest Exception:  MDC{}" + Strings.LINE_SEPARATOR);
    logger.info("Info Message");
    verify("List", "o.a.l.l.j.LoggerTest Info Message MDC{}" + Strings.LINE_SEPARATOR);
    logger.info("Info Message {}");
    verify("List", "o.a.l.l.j.LoggerTest Info Message {} MDC{}" + Strings.LINE_SEPARATOR);
}
Also used : Log(org.apache.commons.logging.Log) Test(org.junit.Test)

Example 64 with Log

use of org.apache.commons.logging.Log in project logging-log4j2 by apache.

the class CallerInformationTest method testMethodLogger.

@Test
public void testMethodLogger() throws Exception {
    final ListAppender app = ctx.getListAppender("Method").clear();
    final Log logger = LogFactory.getLog("MethodLogger");
    logger.info("More messages.");
    logger.warn("CATASTROPHE INCOMING!");
    logger.error("ZOMBIES!!!");
    logger.warn("brains~~~");
    logger.info("Itchy. Tasty.");
    final List<String> messages = app.getMessages();
    assertEquals("Incorrect number of messages.", 5, messages.size());
    for (final String message : messages) {
        assertEquals("Incorrect caller method name.", "testMethodLogger", message);
    }
}
Also used : Log(org.apache.commons.logging.Log) ListAppender(org.apache.logging.log4j.core.test.appender.ListAppender) Test(org.junit.Test)

Example 65 with Log

use of org.apache.commons.logging.Log in project logging-log4j2 by apache.

the class CallerInformationTest method testClassLogger.

@Test
public void testClassLogger() throws Exception {
    final ListAppender app = ctx.getListAppender("Class").clear();
    final Log logger = LogFactory.getLog("ClassLogger");
    logger.info("Ignored message contents.");
    logger.warn("Verifying the caller class is still correct.");
    logger.error("Hopefully nobody breaks me!");
    final List<String> messages = app.getMessages();
    assertEquals("Incorrect number of messages.", 3, messages.size());
    for (final String message : messages) {
        assertEquals("Incorrect caller class name.", this.getClass().getName(), message);
    }
}
Also used : Log(org.apache.commons.logging.Log) ListAppender(org.apache.logging.log4j.core.test.appender.ListAppender) Test(org.junit.Test)

Aggregations

Log (org.apache.commons.logging.Log)188 Test (org.junit.Test)51 Test (org.junit.jupiter.api.Test)40 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)35 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)19 BeanFactory (org.springframework.beans.factory.BeanFactory)17 CountDownLatch (java.util.concurrent.CountDownLatch)15 LogConfigurationException (org.apache.commons.logging.LogConfigurationException)15 ArrayList (java.util.ArrayList)12 File (java.io.File)11 QueueChannel (org.springframework.integration.channel.QueueChannel)11 MethodInvocation (org.aopalliance.intercept.MethodInvocation)10 IOException (java.io.IOException)9 AtomicReference (java.util.concurrent.atomic.AtomicReference)9 Log4JLogger (org.apache.commons.logging.impl.Log4JLogger)9 Message (org.springframework.messaging.Message)8 List (java.util.List)7 ApplicationEventPublisher (org.springframework.context.ApplicationEventPublisher)7 InputStream (java.io.InputStream)6 LogFactory (org.apache.commons.logging.LogFactory)6