} catch (Exception e) {
if (logger.isErrorEnabled()) {
final String msg = "Unexpected error while listening on port " + receivePort;
logger.error(msg, e);
}
}
But when building the code, I get this error:
[ERROR] org.openhab.binding.anel.internal.AnelHandler.java:[270]
Format should be constant. Use placeholder to reduce the needless cost of parameter construction. see http://www.slf4j.org/faq.html#logging_performance
However, there is no method available to log a throwable with a message with placeholder parameters?
This is why I use isErrorEnabled(), but the error is still reported. What do I miss?
That depends. If user interactions is required, probably WARN. If user interaction is required, but the thing status is updated, no need to log at all, set the thing status with the message. If there is nothing the user can do (except waiting) but it may reduce user experience, then INFO would be a good choice. If it „just happens“ and has no consequences, log to DEBUG.