I want to generate a custom Logger in log4j2. I tried the following described here:
java -cp log4j-core-2.6.jar org.apache.logging.log4j.core.tools.Generate$CustomLogger Logger TEST=550 PRODUKTION=200 > Logger.java
I got the log4j-core-2.6.jar file from here. If I try to run the command in my terminal(I use osx10.11.5) I get the following error:
Error: Main method not found in class org.apache.logging.log4j.core.tools.Generate, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
Do you know what I'm doing wrong?
Kindly Regards!
EDIT: Thanks to Alexandre Cartapanis I had to change the command as follows:
java -cp log4j-core-2.6.jar 'org.apache.logging.log4j.core.tools.Generate$CustomLogger' MyLogger TEST=550 PRODUKTION=200 > Logger.java
Try to surround the command with ''.
Here the error says that java cannot found a main method in the "org.apache.logging.log4j.core.tools.Generate" class, but the main method is in "org.apache.logging.log4j.core.tools.Generate$CustomLogger".
Probably a trouble with the "$" in the class name. I'm not an expert into macos shell, but i think the solution is to escape the "$" character.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With