I see some of the more preferred logging frameworks like log4j, log4net etc all use 'trace, debug' etc methods.
Why do they use these instead of methods that take something like a enum level?
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.
Sign up to join this communityLog4j, at least, has both. The methods with just the log level name such as logger.debug(...)
are convenience methods that simply call logger.log(DEBUG, ...)
. You can read more about this at the Custom Log Levels documentation page:
Convenience Methods for the Built-in Log Levels
The built-in log levels have a set of convenience methods on the Logger interface that makes them easier to use. For example, the Logger interface has fourteen
debug()
methods that support the DEBUG level:// convenience methods for the built-in DEBUG level debug(Marker, Message) debug(Marker, Message, Throwable) ...