On Wed, 13 Aug 2008 19:25:03 -0700 (PDT)
lanes <[EMAIL PROTECTED]> wrote:
Hi Jake,
First thanks for your quick reply.
What do you mean ensuring each application will use their own respective
configuration?
Is it by reconfigure it using DOMConfigure / PropertyConfigurator explicitly
inside each application?
Whether you manually configure using DOM or Property Confgurator or let Log4j
auto-configure itself is irrelevant to whether each application will use its
own respective configuration. In the simple case, where no custom logger
repository selector has been defined, it's all about classloader visibility
and behavior.
If you use standard Java parent-first classloading behavior, then if an
instance of log4j exists in a parent classloader that both app1 and app2 can
see, then they will both use that instance of Log4j. This instance of log4j
will attempt to auto-configure itself upon the first loading of
LogManager.class (triggered by any Logger.getLogger("somename") statement).
Usually one would put log4j.xml in the classpath alongside log4j.jar in the
same parent classloader so that Log4j can see the configuration, allowing
auto-configuration to succeed. The point about manual configuration is that
if you have multiple apps performing it, you will not only be overriding the
default configuration but also changing for the configuration for a shared
logger repository. Each app that reconfigures will affect all apps sharing
that logger repository.
After read your URL about logger repository, i'm quite surprise that the
first line in the URL says :
"Log4j, by default, uses a single logger repository. So, unless you log
within the context of your own custom logger repository, the last
entity to configure Log4j will have configured Log4j for every app
using the default logger repository."
well, that's why other application's configurations also affected after i
configure my log4j inside my application.
Yep. This is fundamental to understand when using log4j (or any logging
utility, for that matter).
Jake
Thanks for your reply.
Regards,
Lanes
--- On Wed, 8/13/08, Jacob Kjome <[EMAIL PROTECTED]> wrote:
From: Jacob Kjome <[EMAIL PROTECTED]>
Subject: Re: strange behavior of my log4j.xml configuration
To: "Log4J Users List" <log4j-user@logging.apache.org>
Date: Wednesday, August 13, 2008, 9:46 PM
Unless you've taken steps to ensure that each application will log using
their
own instance of log4j or use a Logger Repository Selector that
distinguishes,
somehow, between applications, then all apps will use the same Logger
Repository (the default one) from a single instance of Log4j.
Most application servers don't use child-first, or parent-last,
classloading
for webapps by default. Tomcat Standalone is one of the only ones out there
that does this by default. Hence, it is usually quite simple to separate
logging per/application under Tomcat. Other appservers may have options to
use child-first classloading. However, many times you'll run into other
issues because it's not well supported on other platforms.
I presume each app is manually configuring iteself? For appservers like
Weblogic of Websphere, I suggest you put both log4j.jar and log4j.xml in the
server classpath and get rid of manual configuration code in your apps.
If you want to explore true logging separation and be able to continue to
manually configure without affecting other apps, then you can look into
using
a repository selector. However, the concept is confusing for many and may
be
more effort than it is worth. I'll let you decide...
http://wiki.apache.org/logging-log4j/AppContainerLogging
Jake
On Wed, 13 Aug 2008 03:50:09 -0700 (PDT)
lanes <[EMAIL PROTECTED]> wrote:
Hi All,
I got a strange behavior when i deploy my application
that define the log4j.xml configuration to existing App.Server (say it
IBM WAS v6.1) then other application's log that already use their own
log file for example App A log to A.log, App B log to B.log will
suddenly redirect to SystemOut.log and no longer to their respective
logs file.
But when i undeploy my application from the App Server, then other
application's log file come back to normal.
Below is my log4j.xml configuration :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration
xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- Appenders -->
<appender name="console"
class="org.apache.log4j.ConsoleAppender">
<param name="DatePattern"
value="'.'yyyy-MM-dd"/>
<param name="Append"
value="true"/>
<param name="Threshold"
value="debug"/>
<param name="Target"
value="System.out" />
<layout
class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%-5p:%d:%c{1} [%x] -
%m%n" />
</layout>
</appender>
<appender name="my_file_a_log"
class="org.apache.log4j.DailyRollingFileAppender">
<param name="File"
value="my_file_a_log.log"/>
<param name="DatePattern"
value="'.'yyyy-MM-dd"/>
<param name="Append"
value="true"/>
<param name="Threshold"
value="debug"/>
<layout
class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%-5p:%d:%c{1} [%x] -
%m%n" />
</layout>
</appender>
<logger name="mycom.mypackage.ClassMyClass"
additivity="false">
<level value="info" />
<appender-ref ref="my_file_a_log" />
</logger>
<root>
<priority value="warn" />
<appender-ref ref="console" />
</root>
</log4j:configuration>
Is it correct?
Am i missing something?
My other question is why other application is affected to my log4j.xml
configuration?
I though every application inside the App.Server will have their own
respective configuration?
Please help me.
your help is really appreciated.
regards,
Lanes
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]