vert-x3 / vertx-4-migration-guide

Migration to Vert.x 4 guide
https://vert-x3.github.io/vertx-4-migration-guide/index.html
20 stars 16 forks source link

SLF4J Log Delegate vs Log4J2 Log Delegate in Vertx 4.3.2. Which one is better? Why? #74

Closed sac10nikam closed 1 year ago

sac10nikam commented 1 year ago

Questions

SLF4J Log Delegate vs Log4J2 Log Delegate in Vertx 4.3.2. Which one is better? Why?

I am using Vertx 3.9.7. Having 'io.vertx.core.logging.Logger' is deprecated . I want to replace it with the new Logger API.

Version

4.3.2

Context

Logging in Vertx 4.3.2 - Migration from 3.9.7 to 4.3.2

Do you have a reproducer?

NA

Steps to reproduce

NA

Extra

JVM 17

sac10nikam commented 1 year ago

@pendula95 @jponge Do you know this?

sac10nikam commented 1 year ago

@pendula95 @jponge I am using something like, private static final LogDelegate LOGGER = new Log4j2LogDelegateFactory().createDelegate( "classname");

Hope this is right.

tsegismont commented 1 year ago

@sac10nikam in Vert.x 4, the vertx logging API is for internal usage only.

If your choice for migration is log4j2, add the dependencies to your project:

<dependencies>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.18.0</version>
  </dependency>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.18.0</version>
  </dependency>
</dependencies>

And then:

/// imports
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

// logger creation
private static final Logger logger = LogManager.getLogger("my-logger");

You no longer need to set a system property for vertx. It will pick up log4j2 automatically on startup as it finds it on the classpath.