# log4j & apache commons logging

**URL:** <https://techcommunity.softwareag.com/t/log4j-apache-commons-logging/57177>\
**Category:** Forum\
**Tags:** Former-Crossvision-Products, Application-Composer\
**Created:** [February 2, 2006, 5:41pm UTC](https://techcommunity.softwareag.com/t/log4j-apache-commons-logging/57177 "2006-02-02T17:41:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serhat](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@Serhat](https://techcommunity.softwareag.com/u/Serhat)\
**Post date:** [February 2, 2006, 5:41pm UTC](https://techcommunity.softwareag.com/t/log4j-apache-commons-logging/57177/1 "2006-02-02T17:41:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mehmet\_Akyuz](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Mehmet\_Akyuz](https://techcommunity.softwareag.com/u/Mehmet_Akyuz)\
**Post date:** [February 8, 2006, 6:08pm UTC](https://techcommunity.softwareag.com/t/log4j-apache-commons-logging/57177/2 "2006-02-08T18:08:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Serhat](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@Serhat](https://techcommunity.softwareag.com/u/Serhat)\
**Post date:** [February 8, 2006, 9:54pm UTC](https://techcommunity.softwareag.com/t/log4j-apache-commons-logging/57177/3 "2006-02-08T21:54:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Bjoern\_Mueller](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@Bjoern\_Mueller](https://techcommunity.softwareag.com/u/Bjoern_Mueller)\
**Post date:** [February 9, 2006, 1:04am UTC](https://techcommunity.softwareag.com/t/log4j-apache-commons-logging/57177/4 "2006-02-09T01:04:11Z")

</div>

…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! 😉  
(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

---

<div class="post-metadata">

**Author:** ![Serhat](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@Serhat](https://techcommunity.softwareag.com/u/Serhat)\
**Post date:** [February 9, 2006, 2:33pm UTC](https://techcommunity.softwareag.com/t/log4j-apache-commons-logging/57177/5 "2006-02-09T14:33:27Z")

</div>

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 :

```auto
 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.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 2:38pm UTC](https://techcommunity.softwareag.com/t/log4j-apache-commons-logging/57177/6 "2021-04-02T14:38:27Z")

</div>


