August 7, 2009 at 12:27 pm
by nitingautam · Filed under log4j, HowTo, Java
Some time the need arises to have our log4j.properties with different name. By default, if no other configuration is given, log4j will search your classpath for a 'log4j.properties' file.
Now to use your own named log4j property add the following line in your main program:
PropertyConfigurator.configure("File name with path")
exmaple:
PropertyConfigurator.configure("c:\\logs\\my-log4j.properties") this will set this as a default property name and all done =)
Permalink
July 23, 2009 at 3:18 pm
by admin · Filed under log4j, Java
This is a very common problem, it occurs when log4j.properties not found in classpath.
Create a file called log4j.properties. Place it in the root folder where your java classes are found. When log4j initializes, it will look for a file named EXACTLY log4j.properties (if you are using a properties file).
Another alternate way is to put the path to the log4j.properties file in your classpath.
Hope this will help you :)
Permalink