Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom slf4j logger within wrapped jar #40

Closed
UnAfraid opened this issue Jan 2, 2017 · 4 comments
Closed

Custom slf4j logger within wrapped jar #40

UnAfraid opened this issue Jan 2, 2017 · 4 comments
Labels

Comments

@UnAfraid
Copy link

UnAfraid commented Jan 2, 2017

As title says

Whenever you build far jar and wrap the jar within the .exe custom loggers aren't discovered somehow

C:\Users\UnAfraid\Desktop>java -jar ClientEditorUI.exe
2017-01-03 00:03:58,251 ERROR Error processing element GUILogger: CLASS_NOT_FOUND
2017-01-03 00:03:58,292 ERROR Unable to locate appender JavaFXLogger for logger

When running the jar:

C:\Users\UnAfraid\Desktop>java -jar ClientEditorUI.jar
[00:03:45] [INFO] MainController: Welcome to the Client Editor!

When you do java -jar the.exe it fails to find it, but when you do java -jar the.jar it works.
Whenever you open the exe with 7z manager lets say all is there the files are there, both config file and the compiled custom logger appender

Here's another report of the very same issue http://stackoverflow.com/questions/39866144/in-launch4j-wrapper-my-custom-log4j2-appender-cant-be-found

My repository with test case https://github.com/UnAfraid/Launch4jPlusSLF4j

Whenever i do dontWrapJar = true it works fine.

@TheBoegl
Copy link
Owner

TheBoegl commented Jan 3, 2017

This seems to me like a problem from log4j2 with your created wrapped jar. If you call the executable with java -Dorg.apache.logging.log4j.simplelog.StatusLogger.level=TRACE -classpath "pathToYourExecutable" you see more details. Even if you set the log4j.configurationFile property programmatically or on the command line it does not help.
Seems like an log4j2 issue to me.

@UnAfraid
Copy link
Author

UnAfraid commented Jan 3, 2017

Its quite weird, how the jar works but the exe doesn't

Here's the log of executing both Output check the difference Here, i can't find any

@TheBoegl
Copy link
Owner

TheBoegl commented Jan 4, 2017

You are not merging the META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat files, hence, the GUILogger.class is not found.

As a work around use the gradle shadow plugin. This will result in an error like this one on SO which was fixed in maven shaded log4j-transformer. See this gist for a possible solution.

@UnAfraid
Copy link
Author

UnAfraid commented Jan 4, 2017

The gist worked, thanks!

TheBoegl added a commit to TheBoegl/shadow-log4j-transformer that referenced this issue Jan 6, 2017
Furthermore this bumps the version to 1.0.1.

As the previous commit message was not linked:
this issues #GradleUp/shadow#207,
fixes TheBoegl/gradle-launch4j#40,
fixes edwgiz/maven-shaded-log4j-transformer#1,
and fixes edwgiz/maven-shaded-log4j-transformer#4.

Signed-off-by: Sebastian Bögl <info@sebastianboegl.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants