Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
The documentation for the Logger and LogBuilder methods which create a log message with parameters (e.g. Logger.error(message, p1, p2, ...)) could probably be improved.
These methods currently only have their message method parameter documented as:
the message to log; the format depends on the message factory.
However, that is not very helpful because in the most common use case (LogManager.getLogger()) you are not even dealing with MessageFactory instances. So it is not clear what a "message factory" is or where to specify one; or even what the default one is.
I would therefore like to request the following changes:
- Logger and LogBuilder should have a section in their class documentation about messages with parameters, this section should explain:
- Default message factory (i.e. used when LogManager.getLogger(...) method without MessageFactory is called); link to ParameterizedMessageFactory (which appears to be the default) and possibly additionally describe directly in Logger and LogManager doc its behavior:
- By default {} is used as placeholder
- Placeholder start { can be escaped using \ (which itself has to be escaped using \ when in front of a {; but only then) (ParameterizedMessageFactory doc currently does not mention that either!)
- Placeholders do not allow any further customization, most importantly they do not support the syntax of JDK's MessageFormat even though it looks similar
- If there are more arguments than placeholders and the last argument is a Throwable it is logged as such (ParameterizedMessageFactory doc currently does not mention that either!)
- If there are more arguments than placeholders, those arguments are ignored (unless the last one is a Throwable, see point above) (ParameterizedMessageFactory doc currently does not mention that either!)
- Link to LogManager methods allowing providing MessageFactory and link to getFormatterLogger(...) methods
- Mention that alternatively log methods accepting Message can be used; link to manual
- Default message factory (i.e. used when LogManager.getLogger(...) method without MessageFactory is called); link to ParameterizedMessageFactory (which appears to be the default) and possibly additionally describe directly in Logger and LogManager doc its behavior:
- All Logger and LogBuilder methods which create messages with parameters should link to these sections described in point 1 (HTML link)
- LogManager methods using the default MessageFactory should document what the default is
Please let me know what you think about this. I will not create a pull request for this if that requires signing the Apache CLA.