Package org.apache.logging.log4j

Examples of org.apache.logging.log4j.Logger


    }

    @Test
    public void testNoLoggers() throws Exception {
        final LoggerContext ctx = Configurator.initialize("Test1", null, "bad/log4j-loggers.xml");
        final Logger logger = LogManager.getLogger("org.apache.test.TestConfigurator");
        final Configuration config = ctx.getConfiguration();
        assertNotNull("No configuration", config);
        assertTrue("Unexpected configuration", DefaultConfiguration.DEFAULT_NAME.equals(config.getName()));
    }
View Full Code Here


    }

    @Test
    public void testBadStatus() throws Exception {
        final LoggerContext ctx = Configurator.initialize("Test1", null, "bad/log4j-status.xml");
        final Logger logger = LogManager.getLogger("org.apache.test.TestConfigurator");
        final Configuration config = ctx.getConfiguration();
        assertNotNull("No configuration", config);
        assertTrue("Unexpected configuration", "XMLConfigTest".equals(config.getName()));
        final LoggerConfig root = config.getLoggerConfig("");
        assertNotNull("No Root Logger", root);
View Full Code Here

    @Test
    public void testFlushAtEndOfBatch() throws Exception {
        final File f = new File("target", "RollingRandomAccessFileAppenderTest.log");
        // System.out.println(f.getAbsolutePath());
        f.delete();
        final Logger log = LogManager.getLogger("com.foo.Bar");
        final String msg = "Message flushed with immediate flush=false";
        log.info(msg);
        ((LifeCycle) LogManager.getContext()).stop(); // stop async thread

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

    }


    @Test
    public void testFailover() throws InterruptedException, IOException {
        final Logger logger = LogManager.getLogger("testFailover");
        logger.debug("Starting testFailover");
        for (int i = 0; i < 10; ++i) {
            final StructuredDataMessage msg = new StructuredDataMessage("Test", "Test Primary " + i, "Test");
            EventLogger.logEvent(msg);
        }
        for (int i = 0; i < 10; ++i) {
View Full Code Here

    @Test
    public void testFlushAtEndOfBatch() throws Exception {
        final File f = new File("target", "RandomAccessFileAppenderTest.log");
        // System.out.println(f.getAbsolutePath());
        f.delete();
        final Logger log = LogManager.getLogger("com.foo.Bar");
        final String msg = "Message flushed with immediate flush=false";
        log.info(msg);
        ((LifeCycle) LogManager.getContext()).stop(); // stop async thread

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

    @Test
    public void validateXmlSchemaThrowable() throws Exception {
        final File file = new File("target", "XmlCompactFileAppenderValidationTest.log.xml");
        file.delete();
        final Logger log = LogManager.getLogger("com.foo.Bar");
        try {
            throw new IllegalArgumentException("IAE");
        } catch (final IllegalArgumentException e) {
            log.warn("Message 1", e);
        }
        Configurator.shutdown(this.loggerContext);
        this.validateXmlSchema(file);
    }
View Full Code Here

    @Test
    public void validateXmlSchema() throws Exception {
        final File file = new File("target", "XmlCompactFileAppenderValidationTest.log.xml");
        file.delete();
        final Logger log = LogManager.getLogger("com.foo.Bar");
        log.warn("Message 1");
        log.info("Message 2");
        log.debug("Message 3");
        Configurator.shutdown(this.loggerContext);
        this.validateXmlSchema(file);
    }
View Full Code Here

    @Test
    public void testLocationIncluded() throws Exception {
        final File f = new File("target", "RollingRandomAccessFileAppenderLocationTest.log");
        // System.out.println(f.getAbsolutePath());
        f.delete();
        final Logger log = LogManager.getLogger("com.foo.Bar");
        final String msg = "Message with location, flushed with immediate flush=false";
        log.info(msg);
        ((LifeCycle) LogManager.getContext()).stop(); // stop async thread

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

        assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1);
    }

    @Test
    public void getLogger_String_MessageFactoryMismatch() {
        final Logger testLogger = testMessageFactoryMismatch("getLogger_String_MessageFactoryMismatch",
            StringFormatterMessageFactory.INSTANCE, ParameterizedMessageFactory.INSTANCE);
        testLogger.debug("%,d", Integer.MAX_VALUE);
        assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1);
        assertEquals(String.format("%,d", Integer.MAX_VALUE), list.strList.get(0));
    }
View Full Code Here

        assertEquals(String.format("%,d", Integer.MAX_VALUE), list.strList.get(0));
    }

    @Test
    public void getLogger_String_MessageFactoryMismatchNull() {
        final Logger testLogger =  testMessageFactoryMismatch("getLogger_String_MessageFactoryMismatchNull",
            StringFormatterMessageFactory.INSTANCE, null);
        testLogger.debug("%,d", Integer.MAX_VALUE);
        assertTrue("Incorrect number of events. Expected 1, actual " + list.strList.size(), list.strList.size() == 1);
        assertEquals(String.format("%,d", Integer.MAX_VALUE), list.strList.get(0));
    }
View Full Code Here

TOP

Related Classes of org.apache.logging.log4j.Logger

Copyright © 2018 www.massapicom. 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.