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 Logger logger = LoggerFactory.getLogger( MyClass.class );
I’m not sure how to proceed.
My Idea is to implement a Custom Logging binding
through implementing the org.slf4j.Logger Interface
What would be the next steps?
My target is to not change the current code
Links I considered:
it should be fairly easy. you’ll need to implement your own
LoggerandLoggerFactory. you will not have to change existing code at all.after doing that you’ll need to implement
StaticLoggerBinderto 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