On my team we have a logging standard, and for the most part the
Logger.log(Level, String, [Throwable])
methods works fine (it gives us automatic timestamp, class name, method name, message, and throwable information in the log). However, we have an additional identifier we log, and it's part of our standard (we use it to help monitor the logs).
My problem is that I want to be able to easily enforce this standard in a fairly painless way. At first we created a wrapper logger class, but the problem is you lose the benefit of Logger knowing which method you are in.
void myLoggerMethod(Level level, String msg, String identifier) {
logger.log(level, identifier + " " + msg);
}
will log things mostly correct, but then it logs the wrong method name. You can use logp to get around this, but then you have to send in the method name as a String and it becomes pretty gross.
Is there a good way to allow people to enter an additional piece of data to log? Is there any extension mechanism that allows this, or something in the API i'm missing?