log4j & apache commons logging

I use apache’s commons-logging framework with log4j for my business layer objects.When I moved business layer into cai , log4j stopped working properly.I put my “log4j.properties” file under WEB-INF /classes as usual but something prevents log4j.(Also put log4j.jar and commonslogging.jar under WEB-INF/lib)
commonslogging framework is still working but all logging functions just writes to stdout like CAI does.
How can I configure log4j to run properly ?

Thanks.

Serdar,

Have you tried putting necessary jar and property files under /appclasses/lib instead of WEB-INF/lib. That is the basic path for CAI applications for additional classes and libraries.

Mehmet.

Hi ,
I use log4j in my “application logic” layer and my “application logic” shared by multiple CAI projects.So I don’t want to duplicate my application logic libraries (and also it’s dependents) under different CAI projects.(This situation doesn’t recommended by Developer’s Guide)
As I know CAI’s class loader checks appclasses directory first to reach classes and if the class is not found, the parent class loader is called ( which means it checks WEB-INF\lib and WEB_INF\classes directories).
Actually I’ve already tested this way.My application layer libraries are all under WEB-INF\lib directory and they all working well except logging.
By the way I applied your comments and they didn’t worked.
Thanks for the response.

…I am no log4j user.

The way you describe our classloader is 100% right: first we check for classes in appclasses/classes across the project(s) and then we take the web application classloader (provided by Tomcat).

From what I understand I see:
(1) The classedd of lg4j are found! :wink:
(2) Log4j ouputs to system.out

My question is: where do you configure log4j - I assume there is some configuration file that is also accessed by the classloader?

Bjoern

I downloaded lastest versions of commons-logging and log4j (1.2.13) and everthing started working.I guess there was a version problem.( But the interesting thing is I use same libraries with another project which is already working as a web application under the same tomcat server.)
What I’m done is I copied commons-logging.jar , commons-logging-API.jar and log4j1.2.13.jar under WEB-INF\lib directory.And I also put log4j.properties file to WEB-INF\classes directory.The content of file is :

 log4j.rootCategory=INFO,stdout,R

##############
# Appenders
#############
# stdout appender
############
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[ADF] %p [%t] %C{1}.%M(%L) | %m%n
##################
#R Appender
################
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=c:/Apache/Tomcat55/logs/ADF.log
log4j.appender.R.MaxFileSize=1024KB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d [ADF] %p [%t] %C{1}.%M(%L) | %m%n


# Log Level for classes
log4j.logger.com.m2m=DEBUG
# Control logging for other open source packages
log4j.logger.org.apache.commons=ERROR
log4j.logger.org.springframework=ERROR
log4j.logger.org.hibernate=ERROR

Thanks for your responses and for your time.