本文整理匯總了Java中org.apache.logging.log4j.core.LogEvent.getSource方法的典型用法代碼示例。如果您正苦於以下問題:Java LogEvent.getSource方法的具體用法?Java LogEvent.getSource怎麽用?Java LogEvent.getSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.logging.log4j.core.LogEvent
的用法示例。
在下文中一共展示了LogEvent.getSource方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: append
import org.apache.logging.log4j.core.LogEvent; //導入方法依賴的package包/類
@Override
public void append(LogEvent event) {
List<LogItem> logItems = new ArrayList<LogItem>();
LogItem item = new LogItem();
logItems.add(item);
item.SetTime((int) (event.getTimeMillis() / 1000));
item.PushBack("time", this.dateFormat.format(new Date(event.getTimeMillis())));
item.PushBack("level", event.getLevel().toString());
item.PushBack("thread", event.getThreadName());
StackTraceElement source = event.getSource();
if (source == null && (!event.isIncludeLocation())) {
event.setIncludeLocation(true);
source = event.getSource();
event.setIncludeLocation(false);
}
item.PushBack("location", source == null ? "Unknown(Unknown Source)" : source.toString());
String message = event.getMessage().getFormattedMessage();
Throwable throwable = event.getThrown();
if (throwable != null) {
for (String s : Throwables.toStringList(throwable)) {
message += System.getProperty("line.separator") + s;
}
}
item.PushBack("message", message);
Map<String, String> properties = event.getContextMap();
if (properties.size() > 0) {
Object[] keys = properties.keySet().toArray();
Arrays.sort(keys);
for (int i = 0; i < keys.length; i++) {
item.PushBack(keys[i].toString(), properties.get(keys[i].toString()));
}
}
producer.send(this.projectName, this.logstore, this.topic, null, logItems, new LoghubAppenderCallback(LOGGER,
this.projectName, this.logstore, this.topic, null, logItems));
}
示例2: resolve
import org.apache.logging.log4j.core.LogEvent; //導入方法依賴的package包/類
@Override
public JsonNode resolve(TemplateResolverContext context, LogEvent logEvent, String key) {
if (!context.isLocationInfoEnabled() || logEvent.getSource() == null) {
return null;
}
int sourceLineNumber = logEvent.getSource().getLineNumber();
return new LongNode(sourceLineNumber);
}
示例3: resolve
import org.apache.logging.log4j.core.LogEvent; //導入方法依賴的package包/類
@Override
public JsonNode resolve(TemplateResolverContext context, LogEvent logEvent, String key) {
if (!context.isLocationInfoEnabled() || logEvent.getSource() == null) {
return null;
}
String sourceMethodName = logEvent.getSource().getMethodName();
return new TextNode(sourceMethodName);
}
示例4: resolve
import org.apache.logging.log4j.core.LogEvent; //導入方法依賴的package包/類
@Override
public JsonNode resolve(TemplateResolverContext context, LogEvent logEvent, String key) {
if (!context.isLocationInfoEnabled() || logEvent.getSource() == null) {
return null;
}
String sourceFileName = logEvent.getSource().getFileName();
return new TextNode(sourceFileName);
}
示例5: resolve
import org.apache.logging.log4j.core.LogEvent; //導入方法依賴的package包/類
@Override
public JsonNode resolve(TemplateResolverContext context, LogEvent logEvent, String key) {
if (!context.isLocationInfoEnabled() || logEvent.getSource() == null) {
return null;
}
String sourceClassName = logEvent.getSource().getClassName();
return new TextNode(sourceClassName);
}