logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Remko Popma <remko.po...@gmail.com>
Subject Re: Log entries written to wrong file
Date Thu, 12 Nov 2015 00:18:00 GMT
What happens if you don't disable the "Use an isolated class loader for
this shared library" option? Is there an error message?

To go back to your original question:
it should be possible to have the log4j jars in the web container's shared
lib and let each web app have its own log4j2.xml config file in
WEB-INF/classes. If you are seeing log entries written to the wrong file
this may be a bug. Is this easy to reproduce?

Unfortunately there are currently a number of memory leaks in versions
2.4.1 and earlier. I have addressed these and the fixes will be in the next
2.5 release. Any help identifying remaining issues (like the issue you
describe) would be great.




On Thu, Nov 12, 2015 at 4:10 AM, Chinh Do <cdo@vienxu.com> wrote:

> I got log separation to work by copying the log4j-core*.jar and
> log4j-api-*.jar to the WAR's lib folder. We are using a Shared Library and
> I also had to disable the option "Use an isolated class loader for this
> shared library" for it to work.
>
> However this is not ideal as disabling "Use an isolated class loader" can
> use up more memory unnecessarily. So I am still trying to get the "Using
> Context Selectors" approach, specifically this part from the manual:
>
> 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.
>
> I am a little lost on exactly what to do though. I tried to define a JVM
> Custom Property named Log4jContextSelector and set it to
> org.apache.logging.log4j.core.selector.JndiContextSelector,
> just to see what happens. After I restarted WAS, this error showed up in
> SystemErr.log: SystemErr R ERROR StatusLogger Unable to lookup
> java:comp/env/log4j/context-name javax.naming.NameNotFoundException: Name
> comp/env/log4j not found in context "java:". So I guess I need to set
> isLog4jContextSelectorNamed, log4jContextName, and log4jConfiguration
> context parameters. But how exactly do you do that for a SpringBoot app
> running in WebSphere 8.5.5?
>
>
> In the process I also upgraded to log4j 2.4.1 to see if it helps with this.
> Don't think the new version makes a difference.
>
> I've been on this for more than 1 week now so any help is greatly
> appreciated.
>
> Chinh
>
>
> On Tue, Nov 10, 2015 at 10:10 AM, Chinh Do <cdo@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, 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 <cdo@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 <cdo@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.popma@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 <cdo@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
> >
>
>
>
> --
> http://www.chinhdo.com - https://twitter.com/chinhdo
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message