Package org.apache.logging.log4j

Examples of org.apache.logging.log4j.LoggingException


        synchronized (this.loggers) {
            logger = this.loggers.get(name);
            if (logger == null) {
                Logger original = factory == null ? LogManager.getLogger(name) : LogManager.getLogger(name, factory);
                if (!(original instanceof AbstractLogger)) {
                    throw new LoggingException(
                            "Log4j Tag Library requires base logging system to extend Log4j AbstractLogger."
                    );
                }
                // wrap a logger from an underlying implementation
                logger = new Log4jTaglibLogger((AbstractLogger) original, name, original.getMessageFactory());
View Full Code Here


            final String[] array = required.split(",");
            if (array.length > 0) {
                for (String str : array) {
                    str = str.trim();
                    if (!mdc.containsKey(str)) {
                        throw new LoggingException("Required key " + str + " is missing from the MDC");
                    }
                }
            }
        }
        final String guid =  UUIDUtil.getTimeBasedUUID().toString();
View Full Code Here

            try {
                final GZIPOutputStream os = new GZIPOutputStream(baos);
                os.write(body);
                os.close();
            } catch (final IOException ioe) {
                throw new LoggingException("Unable to compress message", ioe);
            }
            super.setBody(baos.toByteArray());
        } else {
            super.setBody(body);
        }
View Full Code Here

    private void checkRequired(final Map<String, String> map) {
        for (final String key : mdcRequired) {
            final String value = map.get(key);
            if (value == null) {
                throw new LoggingException("Required key " + key + " is missing from the " + mdcId);
            }
        }
    }
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);
View Full Code Here

        // set appender on root and set level to debug
        root.addAppender(appender);
        root.setAdditive(false);
        root.setLevel(Level.DEBUG);
        root.debug("This is a test message");
        final Throwable child = new LoggingException("This is a test");
        root.error("Throwing an exception", child);
        root.debug("This is another test message");
        Thread.sleep(250);
        LogEvent event = list.poll(3, TimeUnit.SECONDS);
        assertNotNull("No event retrieved", event);
View Full Code Here

        ThreadContext.remove("key2");

        root.error("finished mdc pattern test", new NullPointerException("test"));

        final Exception parent = new IllegalStateException("Test");
        final Throwable child = new LoggingException("This is a test", parent);

        root.error("Throwing an exception", child);

        appender.stop();
View Full Code Here

        super(name, null, null, false);
    }

    @Override
    public void append(final LogEvent event) {
        throw new LoggingException("Always fail");
    }
View Full Code Here

    @Override
    public void append(final LogEvent event) {
        if (fail) {
            fail = false;
            throw new LoggingException("Always fail");
        } else {
            events.add(event);
        }
    }
View Full Code Here

    private AlwaysFailAppender(String name) {
        super(name, null, null, false);
    }

    public void append(LogEvent event) {
        throw new LoggingException("Always fail");
    }
View Full Code Here

TOP

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

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.