About
logging in Vertx is managed by the Vertx Logger
The Vertx logger is a facade for logging system. It uses the JUL logger as default logging engine. You may change it
Example
You can set Vertx to use Log4j via the vertx.logger-delegate-factory-class-name system property.
For instance in the Launcher
public class MainLauncher extends io.vertx.core.Launcher {
static {
System.setProperty("vertx.logger-delegate-factory-class-name", "io.vertx.core.logging.Log4j2LogDelegateFactory");
}
...
}
Management
Change
By default, Vertx uses the JUL logger. If you want to use another logger, you need to perform this steps:
- the system property called vertx.logger-delegate-factory-class-name must be set to the class name of the delegate for your logging system.
- the logging system jar must be added as a dependency (ie must be in the classpath)
Example of how to set the system property by logging system:
java -Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory -Dlog4j.configuration=log4j.xml
System.setProperty("vertx.logger-delegate-factory-class-name", "io.vertx.core.logging.SLF4JLogDelegateFactory");
// version 1
java -Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.Log4jLogDelegateFactory -Dlog4j.configuration=log4j.xml
// version 2
java -Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.Log4j2LogDelegateFactory -Dlog4j.configuration=log4j.xml
java -Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory -Dlogback.configurationFile=logback.xml