Using the Java Logging Configuration File Without Command Line
By the way, I found a solution to my problem with the logging configuration file that I reported here. The problem was to find an evidence that the logging configuration file could be referenced without changing the command line to add the parameter:
Why not change the command line? Basically, because I want to avoid command lines and continue clicking twice on the .jar file to open the application or enable a personalized logging if the application is distributed by Java Webstart.
If the logging configuration file doesn’t exist, I want to generate this file according to the initial needs of the application. A basic need is to store logging files in a separate folder called log, placed in the same folder where the application is executed (working directory). The content of this file should be in xml to be processed afterwards by a logging analyzer. So, I implemented the following code in the main class (class where I implement the main method to initialize the application):
This way, you can enable and better organize the logging of your application without any additional configuration. If you want to execute the application by command line it is still simple:
java -jar myapp.jar
Or simply click twice on the file in most of the cases. The point about this post is not only teach you about logging stuff, but also motivate you to keep things simple to the final user.