Hi Janetta, On Sat, 5 Oct 2024 at 23:07, Jannetta Steyn <jannetta.st...@newcastle.ac.uk.invalid> wrote: > I hope someone is able to help me. I have written a Java application that > uses log4j2. I am using the Idea IDE. When I run the application in Idea the > logging works fine. I have three appenders, one to the console and two to > files. However, when I package the application into a runnable jar with all > its dependencies, and then run it from the command line, log4j2 still creates > the two files but there is no logging - not to the files or the console.
Did you check our FAQ entry about Single-JAR applications[1]? There are basically two techniques to do it: * Putting all the dependency JARs as file entries into the Single JAR and using a small embedded launcher to access them at runtime. This is what Spring Boot Maven Plugin[2] does and it is trivial to use. * Unzipping all the dependency files and putting them into a Single JAR (Shadowing/Shading). This technique risks overriding many files that have the same name, but come from different dependencies. There are workarounds for this problem, but you need to merge each pair of conflicting files. For Log4j the list of files that can cause conflicts is listed in [1]. It is possible to obtain a working application using Maven Shade Plugin (and a lot of transformers), but the Maven Assembly Plugin (that you are using) is not able to do that. Summarising: replace Maven Assembly Plugin with Spring Boot Maven Plugin[2] and your Single JAR Executable will work. Piotr [1] https://logging.apache.org/log4j/2.x/faq.html#single-jar [2] https://docs.spring.io/spring-boot/maven-plugin/packaging.html --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org