You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by BobbyBear <rc...@hotmail.com> on 2014/04/05 01:54:04 UTC

Re: log4j2 initialized too early?

I have a small eclipse project at

https://github.com/rcasazza/TestLog4j2

which shows the issue.

DaBean is a Stateless EJB with a property called "logger" which is
initialized to log4j2.

There are two lines which allow me to initialize it in two different ways:

[1] initializing it with "static" creates a log file called
".${web:contextPath}.log" which is incorrect

[2] initializing it without "static" create a log file called
"TestLog4j2.log" which is correct

I am using tomcat 7.0.53 but have seen the behavior with 7.0.52 as well. I
pulled the latest trunk for tomee to see if the issue has gone away, but it
has not. 

By creating a war for each scenario and deploying, starting and stopping in
tomcat/bin... you will see the log files created there upon startup.





--
View this message in context: http://openejb.979440.n4.nabble.com/log4j2-initialized-too-early-tp4668307p4668598.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: log4j2 initialized too early?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Actually you can but not while log4j2 web integration is this one. They can
rely on a tomcat listener to get it working.
Le 5 avr. 2014 17:01, "BobbyBear" <rc...@hotmail.com> a écrit :

>
> i'm fine with option [3], i didn't realize you shouldn't (can't) use static
> loggers in EJBs.
>
> not looking to create work for something that shouldn't be done.
>
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/log4j2-initialized-too-early-tp4668307p4668609.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: log4j2 initialized too early?

Posted by BobbyBear <rc...@hotmail.com>.
i'm fine with option [3], i didn't realize you shouldn't (can't) use static
loggers in EJBs.

not looking to create work for something that shouldn't be done.





--
View this message in context: http://openejb.979440.n4.nabble.com/log4j2-initialized-too-early-tp4668307p4668609.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: log4j2 initialized too early?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Ok go it

log4J uses a servlet container initialzer to get web info which is of
course initialized after openejb part of tomee and ejb are scanned (so
loaded) before.

You can consider this issue from several point of view:
1) this is an openejb issue which shouldn't load classes before -> if
we fix it we loose so much control of the apps that ears will be
totally broken and potentially a lot of wars too. (I dont get too much
into details here but I'm really -1 for it + wouldnt be before 1-2
months I guess since needs advanced changes)
2) this is a log4j issue -> log4j could use some tomcat internals (or
jmx) to get the info too I think
3) not a reall issue since you can not use static loggers



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



2014-04-05 1:54 GMT+02:00 BobbyBear <rc...@hotmail.com>:
> I have a small eclipse project at
>
> https://github.com/rcasazza/TestLog4j2
>
> which shows the issue.
>
> DaBean is a Stateless EJB with a property called "logger" which is
> initialized to log4j2.
>
> There are two lines which allow me to initialize it in two different ways:
>
> [1] initializing it with "static" creates a log file called
> ".${web:contextPath}.log" which is incorrect
>
> [2] initializing it without "static" create a log file called
> "TestLog4j2.log" which is correct
>
> I am using tomcat 7.0.53 but have seen the behavior with 7.0.52 as well. I
> pulled the latest trunk for tomee to see if the issue has gone away, but it
> has not.
>
> By creating a war for each scenario and deploying, starting and stopping in
> tomcat/bin... you will see the log files created there upon startup.
>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/log4j2-initialized-too-early-tp4668307p4668598.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.