loki4j / loki-logback-appender

Fast and lightweight implementation of Logback appender for Grafana Loki
https://loki4j.github.io/loki-logback-appender/
BSD 2-Clause "Simplified" License
300 stars 26 forks source link

The current releases are not JPMS-compatible #122

Closed zalavaari closed 2 years ago

zalavaari commented 2 years ago

The current releases of the loki-logback-appender contains all of the dependencies, therefore it cannot be used in a modular Java 11+ project because of package collisions.

Is it possible to provide another loki-logback-appender artifact, which contains only the project's own files?

The loki-logback-appender can be JPMS-compatible even without a proper module-info.java, if these dependencies won't be in the jar.

nehaev commented 2 years ago

Hi @zalavaari,

Thanks for reporting this!

The current releases of the loki-logback-appender contains all of the dependencies, therefore it cannot be used in a modular Java 11+ project because of package collisions.

Could you please specify what particular packages do you mean here?

zalavaari commented 2 years ago

Hi!

com.google.protobuf for example.

But sorry, there was a misunderstanding on our side: Modular usage is not a problem, since we don't need a direct dependency for the module loki.logback.appender in a regular use case. (I'm not quite understand the reason of this, but I guess there might be some black magic under the hood around logback, and - in our case - slf4j)

However the problem might still be valid for non-modular (classpath-based) apps too, even if there won't be an error message or a warning in that case. For example in projects, where protobuf is already used, there could be two different protobuf versions on the classpath easily. In that case you won't have control on which version of the protobuf classes will be loaded, since it will depends on the loading order of the jars, instead of the maven/gradle version definition. Therefore the class versions might be different when you run your project directly, or when running it from an IDE.

nehaev commented 2 years ago

Yeah, this makes sense. I'll put everything into com.github.loki4j package to avoid possible collisions.

nehaev commented 2 years ago

The fix was published in v1.3.0-rc1 (release page). Feel free to re-open this ticket or create a new one in case of any issues.