Implement Custom Logger with slf4j

后端 未结 2 1266
萌比男神i
萌比男神i 2020-12-05 09:36

I want to implement a Custom logger which logs all log entries to a Database. Currently my app logs this way (slf4j and log4j binding):

private static final          


        
2条回答
  •  清歌不尽
    2020-12-05 10:15

    You do not have to write your own logging implementation, how about switching the logging framework to logback? Loback supports logging to database natively. As you use the SLF4J API both times your code won't change.

    Take a look at the ch.qos.logback.classic.db.DBAppender. If the default table layout does not fit your needs, you can implement ch.qos.logback.classic.db.names.DBNameResolver to customzie the table and coloum names.

提交回复
热议问题