开发者

LOG4J call only for specific function

开发者 https://www.devze.com 2023-03-02 19:03 出处:网络
asking this as an experiences Log4j user: We have a pretty big class with lots of debug statements (Logger.getLogger(class).debug(\"Borrowed connection \"+con.getId())... you know what I mean :)

asking this as an experiences Log4j user:

We have a pretty big class with lots of debug statements (Logger.getLogger(class).debug("Borrowed connection "+con.getId())... you know what I mean :)

Now 开发者_运维知识库I suspect one specific function to not work as expected and I want only this one particular function to log the debug output, the rest of the Class should keep the "error" level.

is there a solution to this? Google wouldn't satisfy my this time :)


You could use an own loger per method even though that may be a little inconvenient.

Logger.getLogger(class.getName()+"#methodName").debug(..)

will allow to define the log lever per method.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号