2

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 :)

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Jannick
  • 2,094
  • 3
  • 17
  • 21

1 Answers1

3

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.

Sebastian Zarnekow
  • 6,609
  • 20
  • 23