You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Rajvinder Pal <ra...@gmail.com> on 2018/08/09 09:18:59 UTC

Log4j2 example required for java enterprise application

Hi,

I am looking for an example to configure log4j2 in a java enterprise
application consisting of Ejbs, WAR and Utility jars. I want to understand
where to place the logging jars, configuration file in a Java EE
application. Can i use a common log4j2.xml for the complete application?

Thanks,
Raj

Re: Log4j2 example required for java enterprise application

Posted by Matt Sicker <bo...@gmail.com>.
Oh, and for some context, the JndiContextSelector can be useful if you
install your log4j2.xml config into JNDI and make it available throughout
your cluster. Then you don't even need to copy the file to each deployment
(and could potentially update it at runtime as well without, again,
redeploying the config file to N servers).

On Thu, 9 Aug 2018 at 10:50, Matt Sicker <bo...@gmail.com> wrote:

> From what I remember, you can add log4j-api and log4j-core (and any other
> logging bridges) to your EE server's shared lib folder (or install as a
> module in JBoss for example), though if it's all in one ear, you could just
> make it a normal library in there.
>
> As for a shared configuration, you can point them all to the same
> log4j2.xml config file, though you can also do the opposite and use a
> config per application (see <
> http://logging.apache.org/log4j/2.x/manual/webapp.html#ContextParams> for
> some more info). The docs about web applications apply equally well to an
> EAR containing a WAR (or more). As for EJBs specifically, I think there's
> an open issue about it already. If not, feel free to submit an issue (and
> PR if possible).
>
> On Thu, 9 Aug 2018 at 04:19, Rajvinder Pal <ra...@gmail.com>
> wrote:
>
>> Hi,
>>
>> I am looking for an example to configure log4j2 in a java enterprise
>> application consisting of Ejbs, WAR and Utility jars. I want to understand
>> where to place the logging jars, configuration file in a Java EE
>> application. Can i use a common log4j2.xml for the complete application?
>>
>> Thanks,
>> Raj
>>
>
>
> --
> Matt Sicker <bo...@gmail.com>
>


-- 
Matt Sicker <bo...@gmail.com>

Re: Log4j2 example required for java enterprise application

Posted by Matt Sicker <bo...@gmail.com>.
From what I remember, you can add log4j-api and log4j-core (and any other
logging bridges) to your EE server's shared lib folder (or install as a
module in JBoss for example), though if it's all in one ear, you could just
make it a normal library in there.

As for a shared configuration, you can point them all to the same
log4j2.xml config file, though you can also do the opposite and use a
config per application (see <
http://logging.apache.org/log4j/2.x/manual/webapp.html#ContextParams> for
some more info). The docs about web applications apply equally well to an
EAR containing a WAR (or more). As for EJBs specifically, I think there's
an open issue about it already. If not, feel free to submit an issue (and
PR if possible).

On Thu, 9 Aug 2018 at 04:19, Rajvinder Pal <ra...@gmail.com> wrote:

> Hi,
>
> I am looking for an example to configure log4j2 in a java enterprise
> application consisting of Ejbs, WAR and Utility jars. I want to understand
> where to place the logging jars, configuration file in a Java EE
> application. Can i use a common log4j2.xml for the complete application?
>
> Thanks,
> Raj
>


-- 
Matt Sicker <bo...@gmail.com>