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?

1 Answer 1


Log4j, 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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.