Is it possible to post logs of underlying libraries to Logstash log stream?
For instance, I use input JDBC plugin with MSSQL JDBC driver and I would like to see logs of the driver library for debug purposes.
Is it possible? I haven't found any related articles on the net.
I want to note that MSSQL JDBC driver librart relies on java.util.logging (JUL) while Logstash utilizes Log4j2 for internal logging purposes.
So, in any case I will need to set up a logging bridge.
I've managed to solve the issue on my own with the steps below.
I'm using 8.5.1 version of Logstash as Docker image.
- Add Apache Log4j JUL Adapter JAR to
/opt/logstash/logstash-core/lib/jars/.
- Set the system property
java.util.logging.manager to org.apache.logging.log4j.jul.LogManager. I did it with the following command in Dockerfile: ENV LS_JAVA_OPTS -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager
- Add required logging configuration to
/opt/logstash/config/log4j2.properties file. In my case I just added the 2 lines to enable FINER logging for com.microsoft.sqlserver.jdbc.internals.SQLServerConnection class:
logger.sqlserverconnection.name = com.microsoft.sqlserver.jdbc.internals.SQLServerConnection
logger.sqlserverconnection.level = trace
Steps 1 and 2 were taken from the Apache guide.