Package org.apache.logging.log4j

Examples of org.apache.logging.log4j.Logger.info()


        final Util.StringContainer container = Util.readLineFromPort(Util.port, Util.timeoutInMs);

        String helloChina = "Hello, \u4E2D\u570B!";

        Logger logger = LogManager.getLogger("splunk.logger");
        logger.info(helloChina);

        synchronized (container) {
            container.wait(Util.timeoutInMs);
        }
View Full Code Here


        ctx = Configurator.initialize("Test1", "customplugin/log4j2-741.xml");
        config = ctx.getConfiguration();
        listAppender = (ListAppender) config.getAppender("List");

        Logger logger = LogManager.getLogger(PluginManagerPackagesTest.class);
        logger.info("this message is ignored");

        List<String> messages = listAppender.getMessages();
        assertEquals(messages.toString(), 1, messages.size());
        assertEquals("abc123XYZ", messages.get(0));
    }
View Full Code Here

            Configuration configuration = ctx.getConfiguration();
            assertNotNull("No configuration", configuration);
            Appender appender = configuration.getAppender("Servlet");
            assertNotNull("No ServletAppender", appender);
            Logger logger = LogManager.getLogger("Test");
            logger.info("This is a test");

        } catch (final IllegalStateException e) {
            fail("Failed to initialize Log4j properly." + e.getMessage());
        }
        initializer.stop();
View Full Code Here

            "true", refs, null, config, null );
        loggerConfig.addAppender(appender, null, null);
        config.addLogger("org.apache.logging.log4j", loggerConfig);
        ctx.updateLoggers();
        Logger logger = ctx.getLogger(CustomConfigurationTest.class.getName());
        logger.info("This is a test");
        final File file = new File(LOG_FILE);
        assertTrue("log file not created", file.exists());
        assertTrue("No data logged", file.length() > 0);

    }
View Full Code Here

        final RuntimeException exception = new RuntimeException("Hello, world!");

        final Logger logger = LogManager.getLogger(this.getClass().getName() +
                ".testPerformanceOfAppenderWith1000Events");
        logger.info("This is a warm-up message.");

        System.out.println("Starting a performance test for JDBC Appender for " + this.databaseType + '.');

        long start = System.nanoTime();
View Full Code Here

        for(int i = 0; i < 1000; i++) {
            if (i % 25 == 0) {
                logger.warn("This is an exception message.", exception);
            } else {
                logger.info("This is an info message.");
            }
        }

        long elapsed = System.nanoTime() - start;
        long elapsedMilli = elapsed / 1000000;
View Full Code Here

            final Error exception = new Error("Goodbye, cruel world!");

            final Logger logger = LogManager.getLogger(this.getClass().getName() +
                    ".testPerformanceOfAppenderWith10000EventsUsingBasicEntity");
            logger.info("This is a warm-up message.");

            System.out.println("Starting a performance test for JPA Appender for " + this.databaseType + '.');

            long start = System.nanoTime();
View Full Code Here

            for(int i = 0; i < 10000; i++) {
                if (i % 25 == 0) {
                    logger.warn("This is an exception message.", exception);
                } else {
                    logger.info("This is an info message.");
                }
            }

            long elapsed = System.nanoTime() - start;
            long elapsedMilli = elapsed / 1000000;
View Full Code Here

        File f = new File("target", "FastFileAppenderTest.log");
        // System.out.println(f.getAbsolutePath());
        f.delete();
        Logger log = LogManager.getLogger("com.foo.Bar");
        String msg = "Message flushed with immediate flush=false";
        log.info(msg);
        ((LifeCycle) LogManager.getContext()).stop(); // stop async thread

        BufferedReader reader = new BufferedReader(new FileReader(f));
        String line1 = reader.readLine();
        reader.close();
View Full Code Here

        File f = new File("target", "FastRollingFileAppenderLocationTest.log");
        // System.out.println(f.getAbsolutePath());
        f.delete();
        Logger log = LogManager.getLogger("com.foo.Bar");
        String msg = "Message with location, flushed with immediate flush=false";
        log.info(msg);
        ((LifeCycle) LogManager.getContext()).stop(); // stop async thread

        BufferedReader reader = new BufferedReader(new FileReader(f));
        String line1 = reader.readLine();
        reader.close();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.