Logger slf4j advantages of formatting with {} instead of string concatenation

It is about string concatenation performance. It’s potentially significant if your have dense logging statements. (Prior to SLF4J 1.7) But only two parameters are possible Because the vast majority of logging statements have 2 or fewer parameters, so SLF4J API up to version 1.6 covers (only) the majority of use cases. The API designers have … Read more

JUL to SLF4J Bridge

You need to call SLF4JBridgeHandler.install(). You also need to enable all log levels at the root logger (reason in excerpt below) in java.util.logging and remove the default console appender. This handler will redirect jul logging to SLF4J. However, only logs enabled in j.u.l. will be redirected. For example, if a log statement invoking a j.u.l. … Read more

What is a simple, effective way to debug custom Kafka connectors?

I will try to reply to your question in a broad way. A simple way to do Connector development could be as follows: Structure and build your connector source code by looking at one of the many Kafka Connectors available publicly (you’ll find an extensive list available here: https://www.confluent.io/product/connectors/ ) Download the latest Confluent Open … Read more

Logback to log different messages to two files

It’s very possible to do something like this in logback. Here’s an example configuration: <?xml version=”1.0″?> <configuration> <appender name=”FILE” class=”ch.qos.logback.core.FileAppender”> <file>logfile.log</file> <append>true</append> <encoder> <pattern>%-4relative [%thread] %-5level %logger{35} – %msg %n</pattern> </encoder> </appender> <appender name=”ANALYTICS-FILE” class=”ch.qos.logback.core.FileAppender”> <file>analytics.log</file> <append>true</append> <encoder> <pattern>%-4relative [%thread] %-5level %logger{35} – %msg %n</pattern> </encoder> </appender> <!– additivity=false ensures analytics data only goes to … Read more

Why not use java.util.logging?

Disclaimer: I am the founder of log4j, SLF4J and logback projects. There are objective reasons for preferring SLF4J. For one, SLF4J allows the end-user the liberty to choose the underlying logging framework. In addition, savvier users tend to prefer logback which offers capabilities beyond log4j, with j.u.l falling way behind. Feature-wise j.u.l may be sufficient … Read more