Implement Custom Logger with slf4j

后端 未结 2 1263
萌比男神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:22

    it should be fairly easy. you'll need to implement your own Logger and LoggerFactory. you will not have to change existing code at all.

    after doing that you'll need to implement StaticLoggerBinder to return your logger factory and class name. if you download the slf4j zip file then you get the source for all the implementations too, just have a look at the StaticLoggerBinder in slf4j-log4j for an example.

    have a look at this link for details : http://www.slf4j.org/faq.html#slf4j_compatible

提交回复
热议问题