Consider the following scenario:
I am writing a Dispatcher Servlet that delegates processing to various handlers depending on the request URL; the handler objects having previously registered themselves for URL patterns, pretty much as Servlets register themselves in web.xml.
When a Handler registers or unregisters itself for a pattern, I want to log a line that includes the action and pattern; and also the current mappings, so that when a subsequent request processing logs a warning that a request was not processed I can go back in the logs and find out the mappings.
The question is how to ensure that lines logged by registerUrlPattern
/unregisterUrlPattern
actually appear in the log file:
It seems to me that these methods should log the mapping changes at INFO level, since it is additional INFO being logged. But the logger's level is WARN so that will not work. The logger get many other messages at INFO level so it is not possible to change its level to INFO in production, except for troubleshooting.
I could log it at WARN level, but qa/usability/customer does not like such warnings to appear.
I can think of the following alternatives:
Change the Logger's level to INFO when logging these lines, possibly by adding a
forceInfo
method in my Logger (which wraps a standard log4j type logger)Use a different Logger for these methods and set its level to INFO
Log at warning level but change the language to indicate that it is not something to be worried about