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


Java LogEvent.getSource方法代码示例

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

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

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

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

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


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