Search in sources :

Example 1 with AppenderLoggingException

use of org.apache.logging.log4j.core.appender.AppenderLoggingException in project logging-log4j2 by apache.

the class FlumeAvroManager method send.

public synchronized void send(final BatchEvent events) {
    if (rpcClient == null) {
        rpcClient = connect(agents, retries, connectTimeoutMillis, requestTimeoutMillis);
    }
    if (rpcClient != null) {
        try {
            LOGGER.trace("Sending batch of {} events", events.getEvents().size());
            rpcClient.appendBatch(events.getEvents());
        } catch (final Exception ex) {
            rpcClient.close();
            rpcClient = null;
            final String msg = "Unable to write to " + getName() + " at " + agents[current].getHost() + ':' + agents[current].getPort();
            LOGGER.warn(msg, ex);
            throw new AppenderLoggingException("No Flume agents are available");
        }
    } else {
        final String msg = "Unable to write to " + getName() + " at " + agents[current].getHost() + ':' + agents[current].getPort();
        LOGGER.warn(msg);
        throw new AppenderLoggingException("No Flume agents are available");
    }
}
Also used : AppenderLoggingException(org.apache.logging.log4j.core.appender.AppenderLoggingException) AppenderLoggingException(org.apache.logging.log4j.core.appender.AppenderLoggingException)

Example 2 with AppenderLoggingException

use of org.apache.logging.log4j.core.appender.AppenderLoggingException in project logging-log4j2 by apache.

the class FlumeAvroManager method send.

@Override
public synchronized void send(final Event event) {
    if (batchSize == 1) {
        if (rpcClient == null) {
            rpcClient = connect(agents, retries, connectTimeoutMillis, requestTimeoutMillis);
        }
        if (rpcClient != null) {
            try {
                rpcClient.append(event);
            } catch (final Exception ex) {
                rpcClient.close();
                rpcClient = null;
                final String msg = "Unable to write to " + getName() + " at " + agents[current].getHost() + ':' + agents[current].getPort();
                LOGGER.warn(msg, ex);
                throw new AppenderLoggingException("No Flume agents are available");
            }
        } else {
            final String msg = "Unable to write to " + getName() + " at " + agents[current].getHost() + ':' + agents[current].getPort();
            LOGGER.warn(msg);
            throw new AppenderLoggingException("No Flume agents are available");
        }
    } else {
        batchEvent.addEvent(event);
        final int eventCount = batchEvent.getEvents().size();
        if (eventCount == 1) {
            nextSend = System.nanoTime() + delayNanos;
        }
        if (eventCount >= batchSize || System.nanoTime() >= nextSend) {
            send(batchEvent);
            batchEvent = new BatchEvent();
        }
    }
}
Also used : AppenderLoggingException(org.apache.logging.log4j.core.appender.AppenderLoggingException) AppenderLoggingException(org.apache.logging.log4j.core.appender.AppenderLoggingException)

Example 3 with AppenderLoggingException

use of org.apache.logging.log4j.core.appender.AppenderLoggingException in project logging-log4j2 by apache.

the class JdbcDatabaseManager method connectAndStart.

@Override
protected void connectAndStart() {
    try {
        this.connection = this.connectionSource.getConnection();
        this.connection.setAutoCommit(false);
        this.statement = this.connection.prepareStatement(this.sqlStatement);
    } catch (final SQLException e) {
        throw new AppenderLoggingException("Cannot write logging event or flush buffer; JDBC manager cannot connect to the database.", e);
    }
}
Also used : SQLException(java.sql.SQLException) AppenderLoggingException(org.apache.logging.log4j.core.appender.AppenderLoggingException)

Example 4 with AppenderLoggingException

use of org.apache.logging.log4j.core.appender.AppenderLoggingException in project logging-log4j2 by apache.

the class JpaDatabaseManager method connectAndStart.

@Override
protected void connectAndStart() {
    try {
        this.entityManager = this.entityManagerFactory.createEntityManager();
        this.transaction = this.entityManager.getTransaction();
        this.transaction.begin();
    } catch (final Exception e) {
        throw new AppenderLoggingException("Cannot write logging event or flush buffer; manager cannot create EntityManager or transaction.", e);
    }
}
Also used : AppenderLoggingException(org.apache.logging.log4j.core.appender.AppenderLoggingException) AppenderLoggingException(org.apache.logging.log4j.core.appender.AppenderLoggingException)

Example 5 with AppenderLoggingException

use of org.apache.logging.log4j.core.appender.AppenderLoggingException in project logging-log4j2 by apache.

the class JmsAppender method append.

@Override
public void append(final LogEvent event) {
    try {
        final Message message = this.manager.createMessage(getLayout().toSerializable(event));
        message.setJMSTimestamp(event.getTimeMillis());
        this.producer.send(message);
    } catch (final JMSException e) {
        throw new AppenderLoggingException(e);
    }
}
Also used : Message(javax.jms.Message) AppenderLoggingException(org.apache.logging.log4j.core.appender.AppenderLoggingException) JMSException(javax.jms.JMSException)

Aggregations

AppenderLoggingException (org.apache.logging.log4j.core.appender.AppenderLoggingException)11 Logger (org.apache.logging.log4j.Logger)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 BufferedReader (java.io.BufferedReader)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 OutputStream (java.io.OutputStream)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 ExecutorService (java.util.concurrent.ExecutorService)1 JMSException (javax.jms.JMSException)1 Message (javax.jms.Message)1 Marker (org.apache.logging.log4j.Marker)1 ThreadContext (org.apache.logging.log4j.ThreadContext)1 NullOutputStream (org.apache.logging.log4j.core.util.NullOutputStream)1 ReadOnlyStringMap (org.apache.logging.log4j.util.ReadOnlyStringMap)1