日志记录堆栈跟踪日志appender

发布于 2025-02-08 11:30:34 字数 430 浏览 0 评论 0原文

我想在stack-trace logstash log appender而不是在消息字段中

public void exceptionsCatcher(JoinPoint joinPoint, RuntimeException e) {
    ...
    log.error("exception  : {} ", e);

    ...
}

我搜索刚刚找到了使用grok从消息字段过滤堆栈 - 跟踪的解决方案,我想在应用程序级别将其设置在堆栈 - 跟踪字段中,而不是在中设置logstash过滤器。

I would like to log the exception stack trace in stack-trace field of logstash log appender instead of being inside the message field

public void exceptionsCatcher(JoinPoint joinPoint, RuntimeException e) {
    ...
    log.error("exception  : {} ", e);

    ...
}

I searched throw community and just found solution with grok to filter out stack-trace from message field, what i would like is to set it at stack-trace field in application level and not in logstash filter .

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帅气称霸 2025-02-15 11:30:37

您不需要额外的配置即可这样做,只需使用日志提供商的正确超载方法,例如,

    public void exceptionsCatcher(JoinPoint joinPoint, RuntimeException e) {
    ...
    log.error("exception : {} " + " some message description perhaps {}",
            e.getLocalizedMessage(), e.getMessage(), e);
    ...
}

第三个标记将堆栈跟踪插入stack-trace属性,在<<< a href =“ https://www.slf4j.org/api/org/slf4j/logger.html” rel =“ nofollow noreferrer”>在这里。

You don't need extra configuration to do so just use proper overloaded method of your log provider, for example

    public void exceptionsCatcher(JoinPoint joinPoint, RuntimeException e) {
    ...
    log.error("exception : {} " + " some message description perhaps {}",
            e.getLocalizedMessage(), e.getMessage(), e);
    ...
}

The third marker will ingest stack trace into stack-trace attribute, find more about other overloaded methods in here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文