log4j.jar : No appenders could be found for logger (com.mchange.v2.resourcepool.BasicResourcePool)

While working with log4j.jar to log various activity messages, many time you may face an Exception "No appenders could be found for logger (com.mchange.v2.resourcepool.BasicResourcePool)" on unix machine. The exception message on console screen looks like as:


log4j:WARN No appenders could be found for logger(com.mchange.v2.resourcepool.BasicResourcePool).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See
http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
This kind of exception is mostly generated when you are not giving absolute path in the "log4j.appender.[appender_name].file" attribute.

Exceptional Configuration




log4j.appender.[appender_name].file=[logfolderName]/logfile.log

Solution

log4j.appender.[appender_name].file=/home/LoginName/[logfolderName]/logfile.log

                                                              or

log4j.appender.[appender_name].file=${EnvVariable}/[logfolderName]/logfile.log

As I found the conclusion for the exception with Exceptional configuration is that in this case log4j.jar tries to create folder with root folder, which is violation of the FileSystem rules of any OS. So that the exception is thrown, and we are not able to get logs, whereas our all the configurations and codes are correct except the part of the configuration.

**If my conclusion is wrong than please correct me

No comments:

Post a Comment