Reputation: 86915
In log4j
it's possible to define log levels by package
as follows:
<logger name="org.springframework.web.servlet.mvc.method.annotation" level="info">
<AppenderRef ref="CONSOLE" />
</logger>
Questin: how can I define the logging for a specific class only? (eg org.springframework.web.servlet.mvc.method.annotation.EndpointHandlerMapping
)? If I just put this into the <logger name
property, nothing is logged anymore.
Upvotes: 11
Views: 12585
Reputation: 151
It should work with fully qualified name as well. Logger.name doesn't have to be package/class only but it could be any name which you want to. When you call LoggerFactory.getLogger("MyLogger"), then you have to use
<Logger name="MyLogger" level="info">
<AppenderRef ref="CONSOLE"/>
</Logger>
Check what is logged when you use logger for package and use logger name from log. What logger name is logged for this class?
Upvotes: 12