To configure Log4J, simply execute one line of code.
In the above example, prop is a Properties instance. You can create it at runtime, read it from a file or get it from a stream whatever is best for you.
From ANYWHERE in ANY code, the following one line of code will get a Logger object, which can be used to log messages.
Using the class name as the logger name is recommended as it allows you, through the Properties file, to redirect logging for one particular class (say a
servlet) to a seperate file.
The static method getLogger knows what to do based on what the configure method did previous to it running.
The ability to find the correct log without making any coding changes is one advantage of using Log4j.