apache / logging-log4j2

Apache Log4j 2 is a versatile, feature-rich, efficient logging API and backend for Java.
https://logging.apache.org/log4j/2.x/
Apache License 2.0
3.33k stars 1.58k forks source link

Log4J in desktop application #2466

Open tmmlsBE opened 4 months ago

tmmlsBE commented 4 months ago

I'm having an issue with Log4J. It doesn't output my messages in a compiled application (compiled using jPackage). It does work when run the jar file.

The issue is described at https://stackoverflow.com/questions/78275297/log4j-doesnt-write-to-file-in-native-os-x-application

Is Log4J2 supported to be used in a compiled native application?

Thanks

vy commented 4 months ago

~@tmmlsBE, Log4j doesn't support native image compilation out-of-the-box currently, see LOG4J2-2649. You need to manually provide the necessary reachability metadata, which pretty much depends on your Log4j configuration. I guess running the application with -Dlog4j2.debug can give you sufficient information on what is missing.~

~@ppkarwasz and I will be working on this ~Q4 this year. In the https://github.com/apache/logging-log4j2/discussions/2364 discussion, we are trying to collect some feedback; feel free to share your experiences/wishes.~

@tmmlsBE, ignore what I said. @ppkarwasz is right. I was fooled by the "It will be able to produce a native package in a platform-specific format" statement in the jpackage manual.

ppkarwasz commented 4 months ago

@vy,

I never used jpackage, but as far as I understood it is just a thin wrapper that unpacks some JAR files and starts up the JVM. In this aspect it should more ressemble the Equinox Launcher than a 100% native application.

That is quite different from GraalVM support discussed in #2364 and we need to check it out separately.