Reputation: 36799
In my log4j.xml, i am having
<logger name="java.sql">
<level value="DEBUG" />
</logger>
But using this, it also enables the logging for the interface Resultset
. If i want to disable the logging for this interface but still want to have the debug logging for statement
, preparedstatement
, etc... How can i do this?
Upvotes: 2
Views: 6674
Reputation: 719596
Log4j does not allow you to control logging based on class or package names per se. Rather, the granularity of logging control with log4j (and similar Java loggers) is determined by the logger names used by the application. If your JDBC driver has different loggers for statements, prepared statements, resultsets and so on, you are fine. However, if it uses a single logger for all of its logging, you would need to resort to some kind of filtering.
For more information, this page has a section on configuring filters in an XML Configuration file, and the Filter javadoc lists the available (standard) filter classes. For example, you can filter based on whether a logging event's message matches a given string.
Having said that, the filtering approach will be cumbersome, especially if there are lots of different messages to be filtered in / out.
Upvotes: 2
Reputation: 10321
You can use individual loggers for each of those classes or packages, but it depends how those classes created there own loggers.
Although, you are better of focusing on the vendor's implementation of those classes instead of focusing on the interfaces.
Upvotes: 0