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");
}
}
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();
}
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations