如何为多行日志输出添加缩进

问题描述

我不认为,我是第一个想要这个的人,但我找不到它的配置。

典型的 logback 日志输出如下所示:

2021-01-07 13:26:04,639 [MyThread] ERROR [] one.of.my.Classes - Some nice error message : java.lang.RuntimeException
java.lang.RuntimeException: null
    at one.of.my.Classes.method0(Classes:123)
    at one.of.my.Classes.method2(Classes:33)
    ...
Caused by: foo.bar.AnotherException: Blah
    at one.of.my.other.Clazz(Foo.java:693)
    ...
2021-01-07 13:26:04,639 [MyThread]  INFO [] one.of.my.Classes - Multi line info message
Second line
Third line
2021-01-07 13:26:04,639 [MyThread]  INFO [] Some other output

为了使输出更易于阅读,也更易于日志解析器处理,我想为属于另一行的行添加缩进,例如:

2021-01-07 13:26:04,639 [MyThread] ERROR [] one.of.my.Classes - Some nice error message : java.lang.RuntimeException
    java.lang.RuntimeException: null
        at one.of.my.Classes.method0(Classes:123)
        at one.of.my.Classes.method2(Classes:33)
        ...
    Caused by: foo.bar.AnotherException: Blah
        at one.of.my.other.Clazz(Foo.java:693)
        ...
2021-01-07 13:26:04,639 [MyThread]  INFO [] one.of.my.Classes - Multi line info message
    Second line
    Third line
2021-01-07 13:26:04,639 [MyThread]  INFO [] Some other output

那么,我如何通过 logback 实现这一点?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)