Java Code Examples for org.jboss.logging.Logger#info()

The following examples show how to use org.jboss.logging.Logger#info() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoggingArquillianTest.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Test
public void testNothing() {
    Logger gouda = Logger.getLogger( "cheese.gouda" );

    gouda.info( "gouda info" );
    gouda.debug( "gouda debug");

    assertTrue( gouda.isTraceEnabled() );
    assertTrue( gouda.isDebugEnabled() );
    assertTrue( gouda.isInfoEnabled() );

    Logger cheddar = Logger.getLogger( "cheese.cheddar" );

    cheddar.info( "cheddar info" );
    cheddar.debug( "cheddar debug" );

    assertFalse( cheddar.isTraceEnabled() );
    assertFalse( cheddar.isDebugEnabled() );
    assertFalse( cheddar.isInfoEnabled() );
}
 
Example 2
Source File: SWARM553Test.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Test
public void doLogging() throws FileNotFoundException {
    String message = "testing: " + UUID.randomUUID().toString();
    Logger logger = Logger.getLogger("br.org.sistemafieg.cliente");
    logger.info(message);
    assertTrue("File not found: " + logFile, new File(logFile).exists());

    BufferedReader reader = new BufferedReader(new FileReader(logFile));
    List<String> lines = reader.lines().collect(Collectors.toList());

    boolean found = false;

    for (String line : lines) {
        if (line.contains(message)) {
            found = true;
            break;
        }
    }

    assertTrue("Expected message " + message, found);


}
 
Example 3
Source File: LoggingArquillianDefaultTest.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Test
public void testNothing() {
    Logger gouda = Logger.getLogger( "cheese.gouda" );

    gouda.info( "gouda info" );
    gouda.debug( "gouda debug");

    assertFalse( gouda.isTraceEnabled() );
    assertFalse( gouda.isDebugEnabled() );
    assertTrue( gouda.isInfoEnabled() );

    Logger cheddar = Logger.getLogger( "cheese.cheddar" );

    cheddar.info( "cheddar info" );
    cheddar.debug( "cheddar debug" );

    assertFalse( cheddar.isTraceEnabled() );
    assertFalse( cheddar.isDebugEnabled() );
    assertTrue( cheddar.isInfoEnabled() );
}
 
Example 4
Source File: ArqLoggingLevelsTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Test
public void testCustomCategory() {
    Logger logger = Logger.getLogger("custom.category");

    logger.info("gouda info");
    logger.debug("gouda debug");
    logger.trace("gouda trace");

    assertFalse(logger.isTraceEnabled());
    assertTrue(logger.isDebugEnabled());
    assertTrue(logger.isInfoEnabled());
}
 
Example 5
Source File: ArqLoggingLevelsTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Test
public void testCustomCategoryChildren() {
    Logger logger = Logger.getLogger("custom.category.children.Something");

    logger.info("gouda info");
    logger.debug("gouda debug");
    logger.trace("gouda trace");

    assertFalse(logger.isTraceEnabled());
    assertTrue(logger.isDebugEnabled());
    assertTrue(logger.isInfoEnabled());
}
 
Example 6
Source File: ArqLoggingLevelsTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Test
public void testRoot() {
    Logger logger = Logger.getLogger("");

    logger.info("gouda info");
    logger.debug("gouda debug");
    logger.trace("gouda trace");

    assertTrue(logger.isTraceEnabled());
    assertTrue(logger.isDebugEnabled());
    assertTrue(logger.isInfoEnabled());
}
 
Example 7
Source File: LoggingServiceActivator.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings("Convert2Lambda")
@Override
protected HttpHandler getHttpHandler() {
    return new HttpHandler() {
        @Override
        public void handleRequest(final HttpServerExchange exchange) {
            final Map<String, Deque<String>> params = new TreeMap<>(exchange.getQueryParameters());
            final String msg = getValue(params, MSG_KEY, DEFAULT_MESSAGE);
            final boolean includeLevel = getValue(params, INCLUDE_LEVEL_KEY, false);
            final int logCount = getValue(params, LOG_COUNT_KEY, 1);
            final boolean logInfoOnly = getValue(params, LOG_INFO_ONLY_KEY, false);
            final boolean logException = getValue(params, LOG_EXCEPTION_KEY, false);
            final String ndcValue = getValue(params, NDC_KEY, null);
            final Set<Logger.Level> logLevels = getLevels(params);
            final String loggerName = getValue(params, LOG_NAME_KEY, null);
            if (ndcValue != null) {
                NDC.push(ndcValue);
            }
            // Assume other parameters are MDC key/value pairs
            for (String key : params.keySet()) {
                MDC.put(key, params.get(key).getFirst());
            }
            final Logger logger = (loggerName == null ? LOGGER : Logger.getLogger(loggerName));
            for (int i = 0; i < logCount; i++) {
                if (logInfoOnly) {
                    logger.info(getMessage(msg, Logger.Level.INFO, includeLevel));
                } else {
                    for (Logger.Level level : logLevels) {
                        if (logException) {
                            logger.log(level, getMessage(msg, level, includeLevel), createMultiNestedCause());
                        } else {
                            logger.log(level, getMessage(msg, level, includeLevel));
                        }
                    }
                }
            }
            // Clear NDC and MDC
            NDC.clear();
            MDC.clear();
            exchange.getResponseSender().send("Response sent");
        }
    };
}