当前位置: 首页>>代码示例>>Java>>正文


Java AppenderLoggingException类代码示例

本文整理汇总了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();
    }
}
 
开发者ID:magrossi,项目名称:es-log4j2-appender,代码行数:18,代码来源:ElasticSearchRestAppender.java

示例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();
 	}
 }
 
开发者ID:magrossi,项目名称:es-log4j2-appender,代码行数:23,代码来源:ElasticSearchRestAppender.java

示例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();
    }
}
 
开发者ID:haneev,项目名称:TweetRetriever,代码行数:17,代码来源:ApiLogAppenderImpl.java

示例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();
	}
}
 
开发者ID:unicesi,项目名称:pascani,代码行数:20,代码来源:PascaniAppender.java

示例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();
	}
}
 
开发者ID:comdata,项目名称:HomeAutomation,代码行数:27,代码来源:WebSocketAppenderImpl.java

示例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);
}
 
开发者ID:jprante,项目名称:log4j2-elasticsearch-http,代码行数:24,代码来源:ElasticsearchHttpClient.java

示例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);
    }
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:19,代码来源:AbstractSocketServerTest.java

示例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);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:17,代码来源:NoSqlDatabaseManager.java

示例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);
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:17,代码来源:RollingRandomAccessFileManager.java

示例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);
    }
}
 
开发者ID:toeasy,项目名称:spring-boot-boilerplate,代码行数:14,代码来源:XNMongoDbConnection.java

示例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);
        }
    }
}
 
开发者ID:PlayPen,项目名称:PVI,代码行数:16,代码来源:WorkspaceLogAppender.java

示例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 {
	}
}
 
开发者ID:omkreddy,项目名称:log4j2-kafka-appender,代码行数:14,代码来源:KafkaAppender.java

示例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);
    }
  }
}
 
开发者ID:nsoft,项目名称:jesterj,代码行数:12,代码来源:DocumentImpl.java

示例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();
  }
}
 
开发者ID:nsoft,项目名称:jesterj,代码行数:15,代码来源:StepImpl.java

示例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);
    }
}
 
开发者ID:jprante,项目名称:log4j2-elasticsearch-http,代码行数:9,代码来源:ElasticsearchHttpConnection.java


注:本文中的org.apache.logging.log4j.core.appender.AppenderLoggingException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。