本文整理汇总了Java中org.apache.logging.log4j.core.appender.AppenderLoggingException类的典型用法代码示例。如果您正苦于以下问题:Java AppenderLoggingException类的具体用法?Java AppenderLoggingException怎么用?Java AppenderLoggingException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AppenderLoggingException类属于org.apache.logging.log4j.core.appender包,在下文中一共展示了AppenderLoggingException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: append
import org.apache.logging.log4j.core.appender.AppenderLoggingException; //导入依赖的package包/类
@Override
public void append(LogEvent event) {
lock.lock();
try {
String json = new String(getLayout().toByteArray(event));
buffered.add(getBulkItem(json));
this.check();
} catch (Exception ex) {
if (!ignoreExceptions()) {
throw new AppenderLoggingException(ex);
} else {
LOGGER.error("Failed to process event.", ex);
}
} finally {
lock.unlock();
}
}
示例2: send
import org.apache.logging.log4j.core.appender.AppenderLoggingException; //导入依赖的package包/类
private void send() {
try {
cancelTimer();
if (buffered.size() > 0) {
StringBuilder bulkRequestBody = new StringBuilder();
for (String bulkItem : buffered) {
bulkRequestBody.append(bulkItem);
}
try {
this.bulkSender.send(bulkRequestBody.toString());
} catch (Exception ex) {
if (!ignoreExceptions()) {
throw new AppenderLoggingException(ex);
} else {
LOGGER.error("Failed to send data to Elastic server.", ex);
}
}
}
} finally {
buffered.clear();
}
}
示例3: append
import org.apache.logging.log4j.core.appender.AppenderLoggingException; //导入依赖的package包/类
@Override
public void append(LogEvent event) {
readLock.lock();
try {
String message = new String(getLayout().toByteArray(event));
messageBuffer.add(message.trim());
} catch (Exception ex) {
if (!ignoreExceptions()) {
throw new AppenderLoggingException(ex);
}
} finally {
readLock.unlock();
}
}
示例4: append
import org.apache.logging.log4j.core.appender.AppenderLoggingException; //导入依赖的package包/类
@Override public void append(LogEvent event) {
readLock.lock();
try {
String thrown = event.getThrown() == null ? ""
: ExceptionUtils.getStackTrace(event.getThrown());
org.pascani.dsl.lib.events.LogEvent e = new org.pascani.dsl.lib.events.LogEvent(
UUID.randomUUID(), event.getLoggerName(),
event.getLevel().name(),
event.getMessage().getFormattedMessage(), thrown,
event.getSource() + "");
producer.produce(e);
} catch (Exception ex) {
if (!ignoreExceptions()) {
throw new AppenderLoggingException(ex);
}
} finally {
readLock.unlock();
}
}
示例5: append
import org.apache.logging.log4j.core.appender.AppenderLoggingException; //导入依赖的package包/类
@Override
public void append(final LogEvent event) {
final StackTraceElement source = event.getSource();
// do nothing in case this comes from the eventbus endpoint
if (EventBusEndpoint.class.getName().equals(source.getClassName())) {
return;
}
readLock.lock();
try {
final byte[] bytes = getLayout().toByteArray(event);
final String message = new String(bytes);
new WebSocketEvent(message);
// EventBusService.getEventBus().post(webSocketEvent);
} catch (final Exception ex) {
if (!ignoreExceptions()) {
throw new AppenderLoggingException(ex);
}
} finally {
readLock.unlock();
}
}
示例6: ElasticsearchHttpClient
import org.apache.logging.log4j.core.appender.AppenderLoggingException; //导入依赖的package包/类
public ElasticsearchHttpClient(String url, String index, String type,
boolean create, int maxActionsPerBulkRequest, long flushSecs, boolean logresponses) {
this.url = url;
this.index = index;
this.type = type;
this.create = create;
this.maxActionsPerBulkRequest = maxActionsPerBulkRequest;
this.logresponses = logresponses;
this.closed = false;
this.service = Executors.newScheduledThreadPool(1);
service.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
try {
flush();
} catch (IOException e) {
logger.error(e.getMessage(), e);
throw new AppenderLoggingException(e);
}
}
}, flushSecs, flushSecs, TimeUnit.SECONDS);
}
示例7: test64KMessages
import org.apache.logging.log4j.core.appender.AppenderLoggingException; //导入依赖的package包/类
@Test
public void test64KMessages() throws Exception {
final char[] a64K = new char[1024 * 64];
Arrays.fill(a64K, 'a');
final String m1 = new String(a64K);
final String m2 = MESSAGE_2 + m1;
if (expectLengthException) {
try {
testServer(m1, m2);
} catch (final AppenderLoggingException are) {
assertTrue("", are.getCause() != null && are.getCause() instanceof IOException);
// Failure expected.
}
} else {
testServer(m1, m2);
}
}
示例8: writeInternal
import org.apache.logging.log4j.core.appender.AppenderLoggingException; //导入依赖的package包/类
@Override
protected void writeInternal(final LogEvent event, final Serializable serializable) {
if (!this.isRunning() || this.connection == null || this.connection.isClosed()) {
throw new AppenderLoggingException(
"Cannot write logging event; NoSQL manager not connected to the database.");
}
final NoSqlObject<W> entity = this.connection.createObject();
if (serializable instanceof MapMessage) {
setFields((MapMessage<?, ?>) serializable, entity);
} else {
setFields(event, entity);
}
this.connection.insertObject(entity);
}
示例9: writeToDestination
import org.apache.logging.log4j.core.appender.AppenderLoggingException; //导入依赖的package包/类
@Override
protected synchronized void writeToDestination(final byte[] bytes, final int offset, final int length) {
try {
if (randomAccessFile == null) {
String fileName = getFileName();
File file = new File(fileName);
FileUtils.makeParentDirs(file);
createFileAfterRollover(fileName);
}
randomAccessFile.write(bytes, offset, length);
size += length;
} catch (final IOException ex) {
final String msg = "Error writing to RandomAccessFile " + getName();
throw new AppenderLoggingException(msg, ex);
}
}
示例10: insertObject
import org.apache.logging.log4j.core.appender.AppenderLoggingException; //导入依赖的package包/类
@Override
public void insertObject(final NoSqlObject<BasicDBObject> object) {
object.set("clientIP", NetUtils.getIp());
object.set("clientName", this.clientName);
try {
this.collection.insert(object.unwrap(), this.writeConcern);
} catch (final MongoException e) {
throw new AppenderLoggingException("Failed to write log event to MongoDB due to error: " + e.getMessage(),
e);
}
}
示例11: append
import org.apache.logging.log4j.core.appender.AppenderLoggingException; //导入依赖的package包/类
@Override
public void append(LogEvent event) {
try {
String message = new String(getLayout().toByteArray(event));
synchronized (logQueue) {
logQueue.add(message);
}
Platform.runLater(this::pumpQueue);
} catch (Exception ex) {
if (!ignoreExceptions()) {
throw new AppenderLoggingException(ex);
}
}
}
示例12: append
import org.apache.logging.log4j.core.appender.AppenderLoggingException; //导入依赖的package包/类
public void append(LogEvent event) {
try {
if (producer != null) {
Future<RecordMetadata> result = producer.send(new ProducerRecord<String, String>(topic, getLayout().toSerializable(event).toString()));
if(syncsend)
result.get();
}
} catch (final Exception e) {
LOGGER.error("Unable to write to kafka for appender [{}].", this.getName(), e);
throw new AppenderLoggingException("Unable to write to kafka in appender: " + e.getMessage(), e);
} finally {
}
}
示例13: setStatus
import org.apache.logging.log4j.core.appender.AppenderLoggingException; //导入依赖的package包/类
@Override
public void setStatus(Status status) {
this.status = status;
try {
log.info(status.getMarker(), statusMessage);
} catch (AppenderLoggingException e) {
if (!Main.isShuttingDown()) {
log.error("Could not contact our internal Cassandra!!!" + e);
}
}
}
示例14: reportDocStatus
import org.apache.logging.log4j.core.appender.AppenderLoggingException; //导入依赖的package包/类
private void reportDocStatus(Status status, Document document, String message, Object... messageParams) {
try {
ThreadContext.put(JesterJAppender.JJ_INGEST_DOCID, document.getId());
ThreadContext.put(JesterJAppender.JJ_INGEST_SOURCE_SCANNER, document.getSourceScannerName());
document.setStatus(status);
log.info(status.getMarker(), message, messageParams);
} catch (AppenderLoggingException | NoHostAvailableException e) {
if (!Main.isShuttingDown()) {
log.error("Could not contact our internal Cassandra!!!" + e);
}
} finally {
ThreadContext.clearAll();
}
}
示例15: insertObject
import org.apache.logging.log4j.core.appender.AppenderLoggingException; //导入依赖的package包/类
@Override
public void insertObject(final NoSqlObject<Map<String, Object>> object) {
try {
client.index(object.unwrap());
} catch (Exception e) {
throw new AppenderLoggingException("failed to write log event to Elasticsearch HTTP: " + e.getMessage(), e);
}
}