From docs:
handlers = 1catalina.org.apache.juli.FileHandler, \
2localhost.org.apache.juli.FileHandler, \
3manager.org.apache.juli.FileHandler, \
java.util.logging.ConsoleHandler
.handlers = 1catalina.org.apache.juli.FileHandler,
java.util.logging.ConsoleHandler
I didn't found any explanation why need write handlers and after .handlers? Are there common rules for similar properties files? Thanks.
The first line declares the set of handlers that can/will be used, the second one assigns handlers to the specific logger (in this case root logger as
.handlers
is not prefixed with anything).Later on in
logging.properties
each handler is configured.To expand on soulcheck's answer, which I didn't understand at first...
The
handlers = ...
line can be seen as a "variable declaration"."I declare a logger of name
1catalina
and typeFileHandler
, a logger of name2localhost
and typeFileHandler
.. a logger of typeConsoleHandler
(not naming the last one since there's only one, so no ambiguity)."On the other hand, the
.handlers
line would be an "assignment"."I assign the 1catalina & console handlers to the root logger. Which means any logging done in the application at all will be forwarded to these handlers (unless overriden)"
The
.
in.handlers
refers to what you're applying that on. In this case, since there's nothing on the left of the.
, you're applying it to the root logger, which all loggers inherit from.But this is exactly the same principle in action in this line:
In this case there is something on the left of the
.
for the.handlers
and that means we don't assign these handlers to the root logger but to a specific logger. With this line you say "I'm overwriting the standard logger->handler assignment for this specific logger. In this case, don't act like you would based on the root logger configuration. In this case, I want you to use only theConsoleHandler
for that logger".So that means that any logging for
MyClass
will be sent only to theConsoleHandler
and not to any other handler. The other classes are no affected by this line.Again I'm just repeating the explanation from soulcheck, but in more detail, which I needed myself to understand the difference.