Formatting slf4j to log message types with colors

前端 未结 5 2238
情书的邮戳
情书的邮戳 2021-02-07 04:55

I am using slf4j for logging in my Java Application. It involves a lot logging and log monitoring.
Sometimes it is really difficult to read and find information from logs w

5条回答
  •  灰色年华
    2021-02-07 04:59

    Two solutions come to my mind. They are not colors, but alternative solutions:

    1. In your File Appender configuration, you can configure the pattern to include the log level (error, warn, etc). Then you can grep the file, to filter messages by level.

    2. You can configure two file appenders (for two separate log files) with different level threshold. For instance, one would log all the logs above debug level (so info, warn, error) into let's say logs.txt and the other would log only the errors logs into errors.txt

    Hope it helps.

提交回复
热议问题