There are 3 parts in my question, short, long and extra I'll start at:
There is a good tutorial / example of how to collect some specificity (for example Apache like Apache?) I mean tutorial which will address the method of developing an application using eclipse, it is a good directory Get into the structure:
bin / conf / Lib> LICENSE.txt
And the longest part of the question is: How is it appropriate to place my log4j.properties without standing my last 4 assembly? I know that there are so many replies like "put it into src / main / resources" and I did it and it now works in development. I've put all of my config files in src / main / resources because I only load configuration files via classpath (.getClassLoader (.) GetResourceAsStream (name)) and I think this is the best practice I put it in the src / main / resources folder then when I run the mvn package log4j.properties are inserted in the jar but it is not exactly what I want. I want to clean jar and in the end when the software is packaged log4j.properties will sit in conf directory and conf, the directory will be somehow on classpath.
The additional question is: Is my attitude loading through classpath? My thinking is that I want to avoid being disturbed with development / production pathologies. When I think that the CP will be configured then everything will be very easy.
I will comment on this by putting the last part of the configuration files about loading the configuration files into classpath Quite a lot is used in Java. It works fine if the configuration has been fixed at the planning time and the file can be embedded in the jar, but in my experience this creates more trouble as it resolves that the configuration should be changed later.
Mainly for this reason two reasons firstly, it really knows which configuration files are actually used and actually makes debug configuration problems more difficult. More than one directory can be included in the classpath, jar (or any other jar) can contain files. Classloading is one of the more difficult topics in Java, and class coding and classpath are usually opaque topics for those who should actually change the configuration. This is a fixed location where the configuration file should be, in this log file with this location It is better to write a line and create an error if the file is missing.
Second, the configuration files in the classpath are sometimes stored in a package that reads the file that matches the classes. This is a natural and best practice for classpath resources, but it is necessary that you want to create a mail set of folders in the directory where your configuration goes, it makes it even more difficult for those who want to create or edit files .
Log4j gives you an option where you can specify the log4j file on the command line when starting with java. I always use that option to specify the exact location for my Lodge 4j configuration file.
Comments
Post a Comment