Package org.apache.logging.log4j

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


        message = "Log #2";
        boolean exceptionCaught = false;

        for (int i = 0; i < 100; ++i) {
            try {
                logger.error(message);
            } catch (final AppenderRuntimeException e) {
                exceptionCaught = true;
                break;
                // System.err.println("Caught expected exception");
            }
View Full Code Here


        server.start();
        Thread.sleep(300);

        msg = null;
        header = null;
        logger.error(message);
        for (int i = 0; i < 5; ++i) {
            Thread.sleep(100);
            if (list.size() > 1) {
                header = list.get(0);
                msg = list.get(1);
View Full Code Here

        }
        assertNotNull("No header", header);
        assertEquals(expectedHeader, header);
        assertNotNull("No message", msg);
        assertEquals(message, msg);
        logger.error(SHUTDOWN);
        server.join();
    }


    private static class TestSocketServer extends Thread {
View Full Code Here

        final long millis = System.currentTimeMillis();

        final Logger logger = LogManager.getLogger(this.getClass().getName() + ".testFactoryMethodConfig");
        logger.debug("Factory logged message 01.");
        logger.error("Error from factory 02.", exception);

        final Statement statement = this.connection.createStatement();
        final ResultSet resultSet = statement.executeQuery("SELECT * FROM fmLogEntry ORDER BY id");

        assertTrue("There should be at least one row.", resultSet.next());
View Full Code Here

    }

    @Test
    public void rewriteTest() throws Exception {
        final Logger logger = LogManager.getLogger(AsyncAppender.class);
        logger.error("This is a test");
        logger.warn("Hello world!");
        Thread.sleep(100);
        final List<String> list = app.getMessages();
        assertNotNull("No events generated", list);
        assertTrue("Incorrect number of events. Expected 2, got " + list.size(), list.size() == 2);
View Full Code Here

    @Test
    public void testException() throws Exception {
        final Logger logger = LogManager.getLogger(AsyncAppender.class);
        final Exception parent = new IllegalStateException("Test");
        final Throwable child = new LoggingException("This is a test", parent);
        logger.error("This is a test", child);
        Thread.sleep(100);
        final List<String> list = app.getMessages();
        assertNotNull("No events generated", list);
        assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size() == 1);
        final String msg = list.get(0);
View Full Code Here

public class CollectionLoggingTest {

    @Test
    public void testSystemProperties() {
        final Logger logger = LogManager.getLogger(CollectionLoggingTest.class.getName());
        logger.error(System.getProperties());
        // logger.error(new MapMessage(System.getProperties()));
    }

    @Test
    public void testSimpleMap() {
View Full Code Here

    }

    @Test
    public void testSimpleMap() {
        final Logger logger = LogManager.getLogger(CollectionLoggingTest.class.getName());
        logger.error(System.getProperties());
        final Map<String, String> map = new HashMap<String, String>();
        map.put("MyKey1", "MyValue1");
        map.put("MyKey2", "MyValue2");
        logger.error(new MapMessage(map));
        logger.error(map);
View Full Code Here

        final Logger logger = LogManager.getLogger(CollectionLoggingTest.class.getName());
        logger.error(System.getProperties());
        final Map<String, String> map = new HashMap<String, String>();
        map.put("MyKey1", "MyValue1");
        map.put("MyKey2", "MyValue2");
        logger.error(new MapMessage(map));
        logger.error(map);
    }

    @Test
    public void testNetworkInterfaces() throws SocketException {
View Full Code Here

        logger.error(System.getProperties());
        final Map<String, String> map = new HashMap<String, String>();
        map.put("MyKey1", "MyValue1");
        map.put("MyKey2", "MyValue2");
        logger.error(new MapMessage(map));
        logger.error(map);
    }

    @Test
    public void testNetworkInterfaces() throws SocketException {
        final Logger logger = LogManager.getLogger(CollectionLoggingTest.class.getName());
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.