How to log FATAL (or any custom log level) with SLF4J and Log4j2

前端 未结 6 1688
粉色の甜心
粉色の甜心 2021-02-05 15:18

I have those specific requirements :

  • Need to be able to log in FATAL level
  • Need to use SLF4J<
6条回答
  •  广开言路
    2021-02-05 15:48

    You could add "FATAL" at the beginning of your message. For example:

    LOGGER.error("FATAL: database connection lost.");
    

    You do lose some things, like filtering based on level, but this may be ok for many people, especially since you're unlikely to filter out FATAL statements (debug and trace, sure).

提交回复
热议问题