What access level should loggers be set to?
-
20-09-2019 - |
Question
I'm using SLF4J with Log4J underneath. What access levels should I be setting my loggers to?
static final Logger logger = LoggerFactory.getLogger(ClassName.class);
Solution
I think you should use private
access level, because every class should have its own copy of logger. Otherwise we can't tell which class really did the log record.
OTHER TIPS
I always set them to private. Is there any reason any other class would need access to this logger?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow