Похожие чаты

How can I get the default Spring Boot Log pattern

even when I define new custom appenders through log4j2 using YML file?

7 ответов

27 просмотров

Why do you need the default when you can specify your own pattern?

Roy- Автор вопроса

For logback there's handy option for this: logback-spring.xml <configuration> <include resource="org/springframework/boot/logging/logback/base.xml"/> <-- your custom specific config --!> </configuration> But I discovered it only recently, and at the moment I work with logback only. Previously for logback and log4j2 what I always did, was simply: - in IDE do lookup over the whole classpath for file "log4j2.*", find the one that comes in spring boot jar - copy the pattern from there ("org/springframework/boot/logging/log4j2/log4j2.xml")

Agent Q | PM me for Paid Support
Why do you need the default when you can specify y...

Why I do the same is for configuring logger for tests. For prod the format is dictated by lots of factors. But for tests I prefer having nice and familiar for many people log format. And boot's format 95% matches to my personal "format of my dream". Why not reuse it?)

Roy- Автор вопроса
Dmytro Buryak
For logback there's handy option for this: logback...

Yes, unfortunately log4j2 requires lots of hacks so I reverted to using default logback

Roy
Yes, unfortunately log4j2 requires lots of hacks s...

For most cases, there's no much difference in the end. Both logback and log4j2 are good. And in most cases those are used through slf4j. So main difference usually ends when initial configuration is done. And both have many appenders for each integration, so that also doesn't matter. The only thing why I prefer to use log4j2 directly in non-library code, if I have power to make that decision, is because of one super-simple and yet super powerful feature: it has lazy evaluation support for parameters. But apart from it, there's no much notable differences, especially if all logging is done through slf4j.

Roy- Автор вопроса

Похожие вопросы

Обсуждают сегодня

Карта сайта