The manual (http://logging.apache.org/log4j/2.x/manual/logsep.html) says
you can follow step (3) below to get log separation. I am not clear on what
values to set for log4jContextName and log4jConfiguration, or how exactly
to do it on WebSphere 8.5 Has anyone done this? Really appreciate any help
in advance.
Using Context Selectors

There are a few patterns for achieving the desired state of logging
separation using ContextSelectors:

   1. Place the logging jars in the container's classpath and set the
   system property "Log4jContextSelector" to
   "org.apache.logging.log4j.core.selector.BasicContextSelector". This will
   create a single LoggerContext using a single configuration that will be
   shared across all applications.
   2. Place the logging jars in the container's classpath and use the
   default ClassLoaderContextSelector. Follow the instructions to
   initialize Log4j 2 in a web application
   <http://logging.apache.org/log4j/2.x/manual/webapp.html>. Each
   application can be configured to share the same configuration used at the
   container or can be individually configured. If status logging is set to
   debug in the configuration there will be output from when logging is
   initialized in the container and then again in each web application.
   3. Follow the instructions to initialize Log4j 2 in a web application
   <http://logging.apache.org/log4j/2.x/manual/webapp.html> and set the
   system property or servlet context parameter Log4jContextSelector to
   org.apache.logging.log4j.core.selector.JndiContextSelector. This will
   cause the container to use JNDI to locate each web application's
   LoggerContext. Be sure to set the isLog4jContextSelectorNamed context
   parameter to true and also set the log4jContextName and
   log4jConfiguration context parameters.

The exact method for setting system properties depends on the container.
For Tomcat, edit $CATALINA_HOME/conf/catalina.properties. Consult the
documentation for other web containers.

More info:
- log4j 2.1 with slf4j 1.7.12
- Not using Async Loggers right now (planning to use it later)
- WebSphere 8.5

On Mon, Nov 9, 2015 at 11:15 AM, Chinh Do <c...@vienxu.com> wrote:

> The manual (http://logging.apache.org/log4j/2.x/manual/logsep.html) says
> you can follow step (3) below to get log separation. I am not clear on what
> values to set for log4jContextName and log4jConfiguration. Has anyone done
> this?
> Using Context Selectors
>
> There are a few patterns for achieving the desired state of logging
> separation using ContextSelectors:
>
>    1. Place the logging jars in the container's classpath and set the
>    system property "Log4jContextSelector" to
>    "org.apache.logging.log4j.core.selector.BasicContextSelector". This will
>    create a single LoggerContext using a single configuration that will be
>    shared across all applications.
>    2. Place the logging jars in the container's classpath and use the
>    default ClassLoaderContextSelector. Follow the instructions to
>    initialize Log4j 2 in a web application
>    <http://logging.apache.org/log4j/2.x/manual/webapp.html>. Each
>    application can be configured to share the same configuration used at the
>    container or can be individually configured. If status logging is set to
>    debug in the configuration there will be output from when logging is
>    initialized in the container and then again in each web application.
>    3. Follow the instructions to initialize Log4j 2 in a web application
>    <http://logging.apache.org/log4j/2.x/manual/webapp.html> and set the
>    system property or servlet context parameter Log4jContextSelector to
>    org.apache.logging.log4j.core.selector.JndiContextSelector. This will
>    cause the container to use JNDI to locate each web application's
>    LoggerContext. Be sure to set the isLog4jContextSelectorNamed context
>    parameter to true and also set the log4jContextName and
>    log4jConfiguration context parameters.
>
> The exact method for setting system properties depends on the container.
> For Tomcat, edit $CATALINA_HOME/conf/catalina.properties. Consult the
> documentation for other web containers.
>
> On Fri, Nov 6, 2015 at 8:43 AM, Chinh Do <c...@vienxu.com> wrote:
>
>> Hi Remko: I am using log4j 2.1 with slf4j 1.7.12. I am not using Async
>> Loggers right now (planning to use it later).
>>
>> Thanks
>>
>> On Thu, Nov 5, 2015 at 5:11 PM, Remko Popma <remko.po...@gmail.com>
>> wrote:
>>
>>> Two quick questions: What is your log4j2 version, and are you using
>>> Async Loggers?
>>>
>>> On Fri, Nov 6, 2015 at 2:17 AM, Chinh Do <c...@vienxu.com> wrote:
>>>
>>>> Hi all,
>>>>
>>>> I am running multiple web apps (WARs) in the same WebSphere instance.
>>>> Each
>>>> web app has its own log4j2.xml and is configured to write to a separate
>>>> log
>>>> file. But I am seeing some log entries being written to the wrong log
>>>> file.
>>>>
>>>> I think the problem is because we are using the log4j JARs in a shared
>>>> lib
>>>> folder.
>>>>
>>>> Is this article from 2012 still relevant to my issue?
>>>> http://articles.qos.ch/sc.html
>>>>
>>>> What's the best way currently to achieve log separating when running
>>>> multiple web apps in the same container?
>>>>
>>>> Thanks in advance
>>>>
>>>> Chinh
>>>>
>>>> --
>>>> http://www.chinhdo.com - https://twitter.com/chinhdo
>>>>
>>>
>>>
>>
>>
>> --
>> http://www.chinhdo.com - https://twitter.com/chinhdo
>>
>
>
>
> --
> http://www.chinhdo.com - https://twitter.com/chinhdo
>



-- 
http://www.chinhdo.com - https://twitter.com/chinhdo

Reply via email to