tinylog-org / tinylog

tinylog is a lightweight logging framework for Java, Kotlin, Scala, and Android
https://tinylog.org
Apache License 2.0
698 stars 82 forks source link

Option to reduce file size #260

Open tcmot opened 2 years ago

tcmot commented 2 years ago

I would like to have a core library.

It doesn't contain too much features.

Only core features.

Tinylog is still too fat.

Don't add features,It immediately becomes Log4j2.

pmwmedia commented 2 years ago

I agree that it would be nice to further reduce the JAR size of tinylog. However, stop adding features would make tinylog to become a stale project. I have another idea. My idea is having a Maven and Gradle plug-in that can remove features from tinylog.

In tinylog 2, the most features of the logging framework are services. This means that the classes are registered in META-INF/services and there are no references in the tinylog core code itself. If there would be a Maven or Gradle plug-in that could remove not needed features / classes from these service files, any bytecode optimizer like ProGuard could remove the not needed classes and all of their depended classes.

Developing such a Maven and Gradle plug-in would not be that difficult, since service files are just plain text files with fully qualified class names on each line. The plug-in itself should have an include and exclude list for fully qualified class names to keep them or remove them from the service files. Maybe, such plug-in exists already. However, I haven't found any on my quick research.