You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by ajaeger <aj...@opentext.com> on 2013/01/24 11:20:11 UTC

Logging configuration in TomEE 1.5.1 with commons-logging and log4j

Hello,

we need some advice regarding logging configuration in TomEE 1.5.1 with
commons-logging and log4j.

We use the following scenario:
- several applications are deployed in TomEE as webapp and/or app
- each application should have its own log file
- each application should be configured separately with an application
specific log4j.xml
- some classes are contained in multiple application but should only log in
one application if configured

In a plain Tomcat it is working as expected due to class loading separation.
How must we configure TomEE to support our scenario?
Is there a way to enable child-first class loading instead of parent-first
class loading in TomEE?

Thanks in advance for your help
Andreas




--
View this message in context: http://openejb.979440.n4.nabble.com/Logging-configuration-in-TomEE-1-5-1-with-commons-logging-and-log4j-tp4660376.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Logging configuration in TomEE 1.5.1 with commons-logging and log4j

Posted by Romain Manni-Bucau <rm...@gmail.com>.
can you reproduce it and share the project?

tested on the snapshot and it works fine with log4j2

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/1/28 tschuler <th...@opentext.com>

> Hi Romain!
>
> Putting log4j.jar only into lib folder of the according web applications is
> not enough:
> The defined log files are just created but all log messages are written
> into
> catalina.log.
>
> Best regards,
> Thomas
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Logging-configuration-in-TomEE-1-5-1-with-commons-logging-and-log4j-tp4660376p4660432.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: Logging configuration in TomEE 1.5.1 with commons-logging and log4j

Posted by tschuler <th...@opentext.com>.
Hi Romain!

Putting log4j.jar only into lib folder of the according web applications is
not enough:
The defined log files are just created but all log messages are written into
catalina.log.

Best regards,
Thomas 



--
View this message in context: http://openejb.979440.n4.nabble.com/Logging-configuration-in-TomEE-1-5-1-with-commons-logging-and-log4j-tp4660376p4660432.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Logging configuration in TomEE 1.5.1 with commons-logging and log4j

Posted by Romain Manni-Bucau <rm...@gmail.com>.
hmm

just put log4j.xml in the classloader of the app (web-inf/classes)

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/1/28 ajaeger <aj...@opentext.com>

> Hello Romain,
>
> here is an example that reproduces our problem.
> LoggingTest.zip
> <http://openejb.979440.n4.nabble.com/file/n4660440/LoggingTest.zip>
>
> A Readme.txt is contained.
>
> Regards,
> Andreas
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Logging-configuration-in-TomEE-1-5-1-with-commons-logging-and-log4j-tp4660376p4660440.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: Logging configuration in TomEE 1.5.1 with commons-logging and log4j

Posted by Saveriu <sa...@gmail.com>.
Hi!

I found a solution:

Just put the log4j.properties and common-logging.properties (or both .xml)
in your application /lib folder (with log4j.jar in it).

Cheers! 



--
View this message in context: http://openejb.979440.n4.nabble.com/Logging-configuration-in-TomEE-1-5-1-with-commons-logging-and-log4j-tp4660376p4660684.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Logging configuration in TomEE 1.5.1 with commons-logging and log4j

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,

the plan was beginning of next month.

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/1/29 ajaeger <aj...@opentext.com>

> Hi Romain,
>
> I can confirm that my sample works with todays snapshot from TomEE 1.5.2.
> We
> tested with 1.5.1 so far.
> Do you have already a release date for 1.5.2?
>
> Thanks
> Andreas
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Logging-configuration-in-TomEE-1-5-1-with-commons-logging-and-log4j-tp4660376p4660444.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: Logging configuration in TomEE 1.5.1 with commons-logging and log4j

Posted by ajaeger <aj...@opentext.com>.
Hi Romain,

I can confirm that my sample works with todays snapshot from TomEE 1.5.2. We
tested with 1.5.1 so far.
Do you have already a release date for 1.5.2?

Thanks
Andreas



--
View this message in context: http://openejb.979440.n4.nabble.com/Logging-configuration-in-TomEE-1-5-1-with-commons-logging-and-log4j-tp4660376p4660444.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Logging configuration in TomEE 1.5.1 with commons-logging and log4j

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Worked fine with your sample on the snapshot
Le 28 janv. 2013 21:40, "ajaeger" <aj...@opentext.com> a écrit :

> Already tried to put log4j.xml in web-inf/classes.
> Exact same behavior than in web-inf/lib.
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Logging-configuration-in-TomEE-1-5-1-with-commons-logging-and-log4j-tp4660376p4660442.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: Logging configuration in TomEE 1.5.1 with commons-logging and log4j

Posted by ajaeger <aj...@opentext.com>.
Already tried to put log4j.xml in web-inf/classes. 
Exact same behavior than in web-inf/lib.




--
View this message in context: http://openejb.979440.n4.nabble.com/Logging-configuration-in-TomEE-1-5-1-with-commons-logging-and-log4j-tp4660376p4660442.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Logging configuration in TomEE 1.5.1 with commons-logging and log4j

Posted by ajaeger <aj...@opentext.com>.
Hello Romain,

here is an example that reproduces our problem.
LoggingTest.zip
<http://openejb.979440.n4.nabble.com/file/n4660440/LoggingTest.zip>  

A Readme.txt is contained.

Regards,
Andreas



--
View this message in context: http://openejb.979440.n4.nabble.com/Logging-configuration-in-TomEE-1-5-1-with-commons-logging-and-log4j-tp4660376p4660440.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Logging configuration in TomEE 1.5.1 with commons-logging and log4j

Posted by Romain Manni-Bucau <rm...@gmail.com>.
once again log4j uses the config of its classloader.

so you have to put everything (jar + conf) in the app

if you dont manage to do it just create a maven project reproducing the
issue runnable with tomee maven plugin to let us have a look

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/1/28 ajaeger <aj...@opentext.com>

> Hi,
>
> no, putting log4j.xml (or log4j2.xml) + "log4j.jar" in the app is not
> enough.
> We had to put log4j.jar in <TOMEE_HOME>/lib and a log4j.xml in each
> webapp/lib.
>
> If we configure a class for logging in webapp A with its log4j.xml
> the same class in webapp B also logs to the same logfile  despite different
> configuration in this log4j.xml
> The log4j.xml which is changed last "wins".
>
> We found that you can only have one global log4j.xml for all apps.
> Is this correct?
> Is there no way to configure logging separately for each webapp?
> Is there a way to enable child-first class loading instead of parent-first
> class loading in TomEE?
>
> Regards
> Andreas
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Logging-configuration-in-TomEE-1-5-1-with-commons-logging-and-log4j-tp4660376p4660433.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: Logging configuration in TomEE 1.5.1 with commons-logging and log4j

Posted by ajaeger <aj...@opentext.com>.
Hi,

no, putting log4j.xml (or log4j2.xml) + "log4j.jar" in the app is not
enough.
We had to put log4j.jar in <TOMEE_HOME>/lib and a log4j.xml in each
webapp/lib.

If we configure a class for logging in webapp A with its log4j.xml
the same class in webapp B also logs to the same logfile  despite different
configuration in this log4j.xml
The log4j.xml which is changed last "wins".

We found that you can only have one global log4j.xml for all apps.
Is this correct?
Is there no way to configure logging separately for each webapp?
Is there a way to enable child-first class loading instead of parent-first
class loading in TomEE? 

Regards
Andreas



--
View this message in context: http://openejb.979440.n4.nabble.com/Logging-configuration-in-TomEE-1-5-1-with-commons-logging-and-log4j-tp4660376p4660433.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Logging configuration in TomEE 1.5.1 with commons-logging and log4j

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,

putting log4j.xml (or log4j2.xml) + "log4j.jar" in the app is not enough?

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/1/24 ajaeger <aj...@opentext.com>

> Hello,
>
> we need some advice regarding logging configuration in TomEE 1.5.1 with
> commons-logging and log4j.
>
> We use the following scenario:
> - several applications are deployed in TomEE as webapp and/or app
> - each application should have its own log file
> - each application should be configured separately with an application
> specific log4j.xml
> - some classes are contained in multiple application but should only log in
> one application if configured
>
> In a plain Tomcat it is working as expected due to class loading
> separation.
> How must we configure TomEE to support our scenario?
> Is there a way to enable child-first class loading instead of parent-first
> class loading in TomEE?
>
> Thanks in advance for your help
> Andreas
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Logging-configuration-in-TomEE-1-5-1-with-commons-logging-and-log4j-tp4660376.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>