I currently have a custom log manager that internally uses java.util.Formatter
. The main issue is that it's not very usable: everything in one file per application, no possibilities to add specific logs in a database, not able to send a mail, ...
So I would like to be able to increase the capabilities our logging system. After a few tests, Log4J is exactly what I need right now. But I would like to avoid the pain to re-change this again in the future, so I plan to use slf4j on top of Log4J.
Even if I'm ready to make a big search/replace in all my codebase to use slf4j, I'm not ready to check each log statement and reformat it to use the {}
format of slf4j.
So my question is: how can I use slf4j interface and tell it that internally it should use a java.util.Formatter
instead of its default one, preferably in one place (meaning not in each class or package)?
Notes: all answers speaking about performances or stating that I shouldn't use j.u.Formatter will be discarded: I need a pragmatic solution to my problem, not launching a debate.
There is patch http://bugzilla.slf4j.org/show_bug.cgi?id=116 which can be modified to suit your needs. The discussion present there can also give further clarity on using util.Formatter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With