Logger.IsDebugEnabled() always return false

log4j

i am new to log4j and i have the following log4j.properties file in my java application
i am working on this in websphere 6.1

log4j.properties file

log4j.rootLogger=info, console

log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout

log4j.package_name=debug

However this is working if i am using only one project as part of my application.If there are multiple projects and i want to use logging facility,logger.isDebugEnabled() always return false.. can anybody suggest a solution for this?

Thanks in advance

Best Answer

Websphere use a classloader for default for each EAR. If you have several Web modules or EJB modules and several files for log4j, only one is loaded by the classloader.

See A Powerful, Easy-to-Use Logging System for configure log4j with several projects in a EAR.

# Set root logger level to INFO and appender to STDOUT.
log4j.rootLogger=INFO, STDOUT

#------------------------------------STDOUT-----------------------------------#
# STDOUT is set to be a ConsoleAppender.
log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender

# STDOUT uses PatternLayout.
log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
log4j.appender.STDOUT.layout.ConversionPattern=%d %-5p (%c.java:%L).%M - %m%n

log4j.appender.STDOUT.Encoding=UTF-8

#-----------------------------------------------------------------------------#

# Specify the logging level for loggers from other libraries

log4j.logger.org.apache.commons.beanutils.BeanUtils=DEBUG

log4j.logger.org.apache.struts.action=DEBUG

log4j.logger.org.apache.struts.tiles=DEBUG

log4j.logger.org.apache.struts.util.ModuleUtils=DEBUG
log4j.logger.org.apache.struts.util.RequestUtils=DEBUG
log4j.logger.org.apache.struts.util.PropertyMessageResources=ERROR

log4j.logger.com.ibm._jsp=DEBUG

May you are missing the log4j.logger. prefix for each particular package.

See more of log4j in http://logging.apache.org/log4j/1.2/manual.html

Related Topic