本文整理汇总了Java中org.apache.logging.log4j.core.LogEvent.getTimeMillis方法的典型用法代码示例。如果您正苦于以下问题:Java LogEvent.getTimeMillis方法的具体用法?Java LogEvent.getTimeMillis怎么用?Java LogEvent.getTimeMillis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.logging.log4j.core.LogEvent
的用法示例。
在下文中一共展示了LogEvent.getTimeMillis方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: format
import org.apache.logging.log4j.core.LogEvent; //导入方法依赖的package包/类
@Override
public final String format(LogEvent event) {
long eventTimeInMillis = event.getTimeMillis();
// handle "old" events that arrived in separate threads after rollover
if (eventTimeInMillis < currentFileTime) {
return doFormat(indexName, eventTimeInMillis);
}
// rollover
if (eventTimeInMillis >= nextRolloverTime && rollingOver.compareAndSet(false, true)) {
rollover(indexName, eventTimeInMillis);
rollingOver.set(false);
}
// happy path - have to check for pending rollover to avoid race conditions
if (!rollingOver.get()) {
return currentName;
}
// fail-safe for pending rollover
return doFormat(indexName, eventTimeInMillis);
}
示例2: append
import org.apache.logging.log4j.core.LogEvent; //导入方法依赖的package包/类
@Override
public void append(final LogEvent logEvent) {
final LogEvent event = LoggingUtils.prepareLogEvent(logEvent);
final InputLogEvent awsLogEvent = new InputLogEvent();
final long timestamp = event.getTimeMillis();
final String message = new String(getLayout().toByteArray(event));
awsLogEvent.setTimestamp(timestamp);
awsLogEvent.setMessage(message);
if (!queue.offer(awsLogEvent) && !queueFull) {
queueFull = true;
} else if (queueFull) {
queueFull = false;
}
}
示例3: resolve
import org.apache.logging.log4j.core.LogEvent; //导入方法依赖的package包/类
@Override
public JsonNode resolve(TemplateResolverContext context, LogEvent logEvent, String key) {
long timestampMillis = logEvent.getTimeMillis();
FastDateFormat timestampFormat = context.getTimestampFormat();
String timestamp = timestampFormat.format(timestampMillis);
return new TextNode(timestamp);
}
示例4: append
import org.apache.logging.log4j.core.LogEvent; //导入方法依赖的package包/类
/**
* This method is optimized with the assumption that at least one listener has set a level which
* requires that the event be sent. This is ensured by modifying the appender's configuration
* whenever a listener is added or removed.
*/
@Override
public void append(final LogEvent event) {
if (this.alertingDisabled) {
return;
}
// If already appending then don't send to avoid infinite recursion
if ((alerting.get())) {
return;
}
setIsAlerting(true);
try {
final boolean isDebugEnabled = logger.isDebugEnabled();
if (isDebugEnabled) {
logger.debug("Delivering an alert event: {}", event);
}
InternalDistributedSystem ds = this.systemRef.get();
if (ds == null) {
// Use info level to avoid triggering another alert
logger.info("Did not append alert event because the distributed system is set to null.");
return;
}
DistributionManager distMgr = (DistributionManager) ds.getDistributionManager();
final int intLevel = logLevelToAlertLevel(event.getLevel().intLevel());
final Date date = new Date(event.getTimeMillis());
final String threadName = event.getThreadName();
final String logMessage = event.getMessage().getFormattedMessage();
final String stackTrace = ThreadUtils.stackTraceToString(event.getThrown(), true);
final String connectionName = ds.getConfig().getName();
for (Listener listener : this.listeners) {
if (event.getLevel().intLevel() > listener.getLevel().intLevel()) {
break;
}
try {
AlertListenerMessage alertMessage =
AlertListenerMessage.create(listener.getMember(), intLevel, date, connectionName,
threadName, Thread.currentThread().getId(), logMessage, stackTrace);
if (listener.getMember().equals(distMgr.getDistributionManagerId())) {
if (isDebugEnabled) {
logger.debug("Delivering local alert message: {}, {}, {}, {}, {}, [{}], [{}].",
listener.getMember(), intLevel, date, connectionName, threadName, logMessage,
stackTrace);
}
alertMessage.process(distMgr);
} else {
if (isDebugEnabled) {
logger.debug("Delivering remote alert message: {}, {}, {}, {}, {}, [{}], [{}].",
listener.getMember(), intLevel, date, connectionName, threadName, logMessage,
stackTrace);
}
distMgr.putOutgoing(alertMessage);
}
} catch (ReenteredConnectException e) {
// OK. We can't send to this recipient because we're in the middle of
// trying to connect to it.
}
}
} finally {
setIsAlerting(false);
}
}