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 "David Tonhofer, m-plify S.A." <d....@m-plify.com> on 2003/02/17 21:04:20 UTC

The twilight zone? Weird interaction of log4j with jakarta POI

Hello people.

I have got a problem that got me stumped a bit (well, not really, but
I wanted to hear what others say about it). In a word: adding
the Jakarta POI jar to the CLASSPATH alters log4j logging behaviour
because an appender shows up on the root Logger. Spooky.

Here's more details:

1) SUN JVM 1.4.1_01 on Windows 2000
2) Jakarta Log4J comes from:  jakarta-log4j-1.2.7.jar
3) Jakarta POI   comes from:  jakarta-poi-1.5.1-final-20020615.jar

Now, I just run a little program (see below) that writes out
the whole Log4J Hierarchy after startup. If the Jakarta POI jar is
in the CLASSPATH, we see two additional appenders (see comments).
This is unnerving because all the log messages show up twice on
stdout if you happen to add your own appender to the root Logger.

I did not know that adding a jar to the CLASSPATH w/o referencing
any class contained in it would change anything. Also, there are
no static initializers in POI...Does Log4J do anything unexpected?

Just to be on the safer side of sure, I tried the stunt on Blackdown
JVM 1.3.1 on a Linux machine. Same result.

It does not happen for IBM JVM 1.2 in the VisualAge IDE, though. Hmm..

So, what's going on?

Best regards,

	-- David Tonhofer


-----------8<--------------------------8<--------------------------

package com.mplify.win2k.diskmon;

import org.apache.log4j.Appender;
import java.util.Enumeration;
import org.apache.log4j.Logger;
import org.apache.log4j.Layout;
import org.apache.log4j.Level;
import org.apache.log4j.TTCCLayout;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.LogManager;

/**********************************************************************
 * Simple test of Log4J.
 * By default, the program just writes out a description of the logging
 * hierarchy to stdout using the System.out PrintStream. If the first
 * argument to the program is 'WITH', a logger is allocated before the
 * logging hierarchy is printed to stdout.
 *
 * With 'jakarta-poi' in the classpath:
 * ====================================
 *
 * WITH Logger allocated
 * LOGGER: root
 *  Level   = DEBUG                                <-- our level for root 
(POI sets it to FATAL)
 *  Additivity = true
 *  Appender name = stdout                         <-- Jakarta-POI 
debugging appender
 *  Appender name = null                           <-- our appender for root
 * LOGGER: com.mplify.win2k.diskmon.Log4JTest.main <-- our method-specific 
logger
 *  Level   = null
 *  Additivity = true
 * LOGGER: org                                     <-- Jakarta-POI specific 
logger
 *  Level   = FATAL                                <-- ...it works at level 
FATAL
 *  Additivity = true
 *  Appender name = stdout                         <-- Jakarta-POI 
debugging appender
 *
 * WITHOUT Logger allocated
 * LOGGER: root
 *  Level   = DEBUG                                <-- our level for root 
(POI sets it to FATAL)
 *  Additivity = true
 *  Appender name = stdout                         <-- Jakarta-POI 
debugging appender
 *  Appender name = null                           <-- our appender for root
 * LOGGER: org                                     <-- Jakarta-POI specific 
logger
 *  Level   = FATAL                                <-- ...it works at level 
FATAL
 *  Additivity = true
 *  Appender name = stdout                         <-- Jakarta-POI 
debugging appender
 *
 * With no 'jakarta-poi' in the classpath:
 * =======================================
 *
 * WITH Logger allocated
 * LOGGER: root
 *  Level   = DEBUG                                 <-- our level for root
 *  Additivity = true
 *  Appender name = null                            <-- our appender for 
root
 * LOGGER: com.mplify.win2k.diskmon.Log4JTest.main  <-- our method-specific 
logger
 *  Level   = null
 *  Additivity = true
 *
 * 20 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is 
message 0
 * 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is 
message 1
 * 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is 
message 2
 * 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is 
message 3
 * 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is 
message 4
 * 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is 
message 5
 * 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is 
message 6
 * 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is 
message 7
 * 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is 
message 8
 * 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is 
message 9
 *
 * WITHOUT Logger allocated
 * LOGGER: root
 *  Level   = DEBUG                                 <-- our level for root
 *  Additivity = true
 *  Appender name = null                            <-- our appender for 
root
 *********************************************************************/

public class Log4JTest {

    private final static String PACKAGE = "com.mplify.win2k.diskmon";
    private final static String CLASS = PACKAGE + ".Log4JTest";

    /**
    * List the whole setup of Log4J's default Hierarchy
    * Except the Renderers which are not listable
    */

    public static void listSetupOfDefaultLog4JHierarchy() {
        StringBuffer buf = new StringBuffer();
        //
        // first the root element of the default hierarchy
        //
        {
            Logger root = Logger.getRootLogger();
            buf.append("LOGGER: ");
            buf.append(root.getName());
            buf.append("\n");
            buf.append(" Level   = ");
            buf.append(root.getLevel());
            buf.append("\n");
            buf.append(" Additivity = ");
            buf.append(root.getAdditivity());
            buf.append("\n");
            Enumeration appEnum = root.getAllAppenders();
            while (appEnum.hasMoreElements()) {
                Appender app = (Appender) (appEnum.nextElement());
                buf.append(" Appender name = ");
                buf.append(app.getName());
                buf.append("\n");
                // may want to check the filter and the layout of the 
appender
            }
        }
        //
        // then for the rest of the categories
        //
        {
            Enumeration enum = LogManager.getCurrentLoggers();
            while (enum.hasMoreElements()) {
                Logger cat = (Logger) (enum.nextElement());
                buf.append("LOGGER: ");
                buf.append(cat.getName());
                buf.append("\n");
                buf.append(" Level   = ");
                buf.append(cat.getLevel());
                buf.append("\n");
                buf.append(" Additivity = ");
                buf.append(cat.getAdditivity());
                buf.append("\n");
                Enumeration appEnum = cat.getAllAppenders();
                while (appEnum.hasMoreElements()) {
                    Appender app = (Appender) (appEnum.nextElement());
                    buf.append(" Appender name = ");
                    buf.append(app.getName());
                    buf.append("\n");
                    // may want to check the filter and the layout of the 
appender
                }
            }
        }
        System.out.println(buf.toString());
    }
    /**
     * Example main() code
     * 2) The TTCCLayout timing info is crap --- Is this also the case in 
UNIX?
     */

    public static void main(String[] argv) {
        Logger logger = null;
        if (argv != null && argv.length >= 1 && 
"WITH".equalsIgnoreCase(argv[0])) {
            logger = Logger.getLogger(CLASS + ".main");
            System.out.println("WITH Logger allocated");
        } else {
            System.out.println("WITHOUT Logger allocated");
        }
        //
        // prepare logging
        //
        Layout layout = new TTCCLayout();
        Logger.getRoot().addAppender(new ConsoleAppender(layout, 
ConsoleAppender.SYSTEM_OUT));
        Logger.getRoot().setLevel(Level.DEBUG);
        //
        // write out how the hierarchy looks now
        //	
        listSetupOfDefaultLog4JHierarchy();
        //
        // then write some stuff
        //
        if (logger != null) {
            for (int i = 0; i < 10; i++) {
                logger.debug("This is message " + i);
            }
        }
    }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Re: Remote control

Posted by Jacob Kjome <ho...@visi.com>.
In addition, check out the ConfigurationServlet in the 
org.apache.log4j.servlet package in log4j-sandbox (CVS only).  I haven't 
tried it yet, but it should provide you with a way to modify your log4j 
settings via the web.

Jake

At 10:55 AM 2/18/2003 +0100, you wrote:
>On Tue, 18 Feb 2003 10:49:38 +0100, Oscar Ruiz wrote:
>
> >Hi all,
> >
> >is there any way of changing logging properties online?, i.e. without
> >restarting the application?, and even more, can this be done remotely?
> >
> >I have a server with multiple java applications, each of them using its own
> >logging properties file, when a problem ocurrs i need to change the
> >properties file in order to enable debuging for the application causing the
> >problems, but obviously restarting changes the whole state of the
> >application, not helping to debug.
>
>Use
>"PropertyConfigurator.configureAndWatch("config/logging.properties");".
>This makes log4j reread the properties file every minute, allowing you
>to update the debug level online.
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org

Re: Remote control

Posted by Ferenc Toth <ft...@eu.infobal.com>.
On Tue, 18 Feb 2003 10:49:38 +0100, Oscar Ruiz wrote:

>Hi all,
>
>is there any way of changing logging properties online?, i.e. without
>restarting the application?, and even more, can this be done remotely?
>
>I have a server with multiple java applications, each of them using its own
>logging properties file, when a problem ocurrs i need to change the
>properties file in order to enable debuging for the application causing the
>problems, but obviously restarting changes the whole state of the
>application, not helping to debug.

Use
"PropertyConfigurator.configureAndWatch("config/logging.properties");".
This makes log4j reread the properties file every minute, allowing you
to update the debug level online. 




---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Remote control

Posted by Oscar Ruiz <os...@gtd.es>.
Hi all,

is there any way of changing logging properties online?, i.e. without
restarting the application?, and even more, can this be done remotely?

I have a server with multiple java applications, each of them using its own
logging properties file, when a problem ocurrs i need to change the
properties file in order to enable debuging for the application causing the
problems, but obviously restarting changes the whole state of the
application, not helping to debug.

Thanks a lot.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Re: The twilight zone? Weird interaction of log4j with jakarta

Posted by "David Tonhofer, m-plify S.A." <d....@m-plify.com>.
Aww....

Actually, I have found out now this it has nothing to do
with bug #13201...it's far simpler. The POI distribution
jar contains a log4j.properties file! It's not clear
why, the POI logging does not use Commons or Log4j logging
at all, it has its own Logging mechanism, the "POILogger".

I should have thought about this immediately, after all the
symptoms "adding the Jakarta POI jar to the CLASSPATH alters
log4j logging behaviour because an appender shows up on the root
Logger" clearly indicates what happens....but I was so fixated
at looking at code.

My belief in a causal world has now been restored.

The bug has been reported already, too:

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12671


--On Monday, February 17, 2003 10:42 PM +0100 Ceki Gülcü <ce...@qos.ch> 
wrote:

>

You have been bitten by #13201 which was discussed a few days ago and
> keeps  rearing its ugly head.
>
> See http://marc.theaimsgroup.com/?t=104497294500002&r=1&w=2
>
> and in particular
>
> http://marc.theaimsgroup.com/?l=log4j-user&m=104498017406236&w=2
>
> To get it fixed, don't forget to vote:
>
> http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13201
>
> At 21:04 17.02.2003 +0100, you wrote:
>> Hello people.
>>
>> I have got a problem that got me stumped a bit (well, not really, but
>> I wanted to hear what others say about it). In a word: adding
>> the Jakarta POI jar to the CLASSPATH alters log4j logging behaviour
>> because an appender shows up on the root Logger. Spooky.
>>
>> Here's more details:
>>
>> 1) SUN JVM 1.4.1_01 on Windows 2000
>> 2) Jakarta Log4J comes from:  jakarta-log4j-1.2.7.jar
>> 3) Jakarta POI   comes from:  jakarta-poi-1.5.1-final-20020615.jar
>>
>> Now, I just run a little program (see below) that writes out
>> the whole Log4J Hierarchy after startup. If the Jakarta POI jar is
>> in the CLASSPATH, we see two additional appenders (see comments).
>> This is unnerving because all the log messages show up twice on
>> stdout if you happen to add your own appender to the root Logger.
>>
>> I did not know that adding a jar to the CLASSPATH w/o referencing
>> any class contained in it would change anything. Also, there are
>> no static initializers in POI...Does Log4J do anything unexpected?
>>
>> Just to be on the safer side of sure, I tried the stunt on Blackdown
>> JVM 1.3.1 on a Linux machine. Same result.
>>
>> It does not happen for IBM JVM 1.2 in the VisualAge IDE, though. Hmm..
>>
>> So, what's going on?
>>
>> Best regards,
>>
>>         -- David Tonhofer
>>
>>
>> -----------8<--------------------------8<--------------------------
>>
>> package com.mplify.win2k.diskmon;
>>
>> import org.apache.log4j.Appender;
>> import java.util.Enumeration;
>> import org.apache.log4j.Logger;
>> import org.apache.log4j.Layout;
>> import org.apache.log4j.Level;
>> import org.apache.log4j.TTCCLayout;
>> import org.apache.log4j.ConsoleAppender;
>> import org.apache.log4j.LogManager;
>>
>> /**********************************************************************
>> * Simple test of Log4J.
>> * By default, the program just writes out a description of the logging
>> * hierarchy to stdout using the System.out PrintStream. If the first
>> * argument to the program is 'WITH', a logger is allocated before the
>> * logging hierarchy is printed to stdout.
>> *
>> * With 'jakarta-poi' in the classpath:
>> * ====================================
>> *
>> * WITH Logger allocated
>> * LOGGER: root
>> *  Level   = DEBUG                                <-- our level for root
>> (POI sets it to FATAL)
>> *  Additivity = true
>> *  Appender name = stdout                         <-- Jakarta-POI
>> debugging appender
>> *  Appender name = null                           <-- our appender for
>> root * LOGGER: com.mplify.win2k.diskmon.Log4JTest.main <-- our
>> method-specific  logger
>> *  Level   = null
>> *  Additivity = true
>> * LOGGER: org                                     <-- Jakarta-POI
>> specific  logger
>> *  Level   = FATAL                                <-- ...it works at
>> level  FATAL
>> *  Additivity = true
>> *  Appender name = stdout                         <-- Jakarta-POI
>> debugging appender
>> *
>> * WITHOUT Logger allocated
>> * LOGGER: root
>> *  Level   = DEBUG                                <-- our level for root
>> (POI sets it to FATAL)
>> *  Additivity = true
>> *  Appender name = stdout                         <-- Jakarta-POI
>> debugging appender
>> *  Appender name = null                           <-- our appender for
>> root * LOGGER: org                                     <-- Jakarta-POI
>> specific  logger
>> *  Level   = FATAL                                <-- ...it works at
>> level  FATAL
>> *  Additivity = true
>> *  Appender name = stdout                         <-- Jakarta-POI
>> debugging appender
>> *
>> * With no 'jakarta-poi' in the classpath:
>> * =======================================
>> *
>> * WITH Logger allocated
>> * LOGGER: root
>> *  Level   = DEBUG                                 <-- our level for root
>> *  Additivity = true
>> *  Appender name = null                            <-- our appender for
>> root * LOGGER: com.mplify.win2k.diskmon.Log4JTest.main  <-- our
>> method-specific  logger
>> *  Level   = null
>> *  Additivity = true
>> *
>> * 20 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is
>> message 0 * 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main -
>> This is message 1 * 30 [main] DEBUG
>> com.mplify.win2k.diskmon.Log4JTest.main - This is message 2 * 30 [main]
>> DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is message 3 * 30
>> [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is message 4
>> * 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is
>> message 5 * 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main -
>> This is message 6 * 30 [main] DEBUG
>> com.mplify.win2k.diskmon.Log4JTest.main - This is message 7 * 30 [main]
>> DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is message 8 * 30
>> [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is message 9
>> *
>> * WITHOUT Logger allocated
>> * LOGGER: root
>> *  Level   = DEBUG                                 <-- our level for root
>> *  Additivity = true
>> *  Appender name = null                            <-- our appender for
>> root
>> *********************************************************************/
>>
>> public class Log4JTest {
>>
>>    private final static String PACKAGE = "com.mplify.win2k.diskmon";
>>    private final static String CLASS = PACKAGE + ".Log4JTest";
>>
>>    /**
>>    * List the whole setup of Log4J's default Hierarchy
>>    * Except the Renderers which are not listable
>>    */
>>
>>    public static void listSetupOfDefaultLog4JHierarchy() {
>>        StringBuffer buf = new StringBuffer();
>>        //
>>        // first the root element of the default hierarchy
>>        //
>>        {
>>            Logger root = Logger.getRootLogger();
>>            buf.append("LOGGER: ");
>>            buf.append(root.getName());
>>            buf.append("\n");
>>            buf.append(" Level   = ");
>>            buf.append(root.getLevel());
>>            buf.append("\n");
>>            buf.append(" Additivity = ");
>>            buf.append(root.getAdditivity());
>>            buf.append("\n");
>>            Enumeration appEnum = root.getAllAppenders();
>>            while (appEnum.hasMoreElements()) {
>>                Appender app = (Appender) (appEnum.nextElement());
>>                buf.append(" Appender name = ");
>>                buf.append(app.getName());
>>                buf.append("\n");
>>                // may want to check the filter and the layout of the
>>                appender }
>>        }
>>        //
>>        // then for the rest of the categories
>>        //
>>        {
>>            Enumeration enum = LogManager.getCurrentLoggers();
>>            while (enum.hasMoreElements()) {
>>                Logger cat = (Logger) (enum.nextElement());
>>                buf.append("LOGGER: ");
>>                buf.append(cat.getName());
>>                buf.append("\n");
>>                buf.append(" Level   = ");
>>                buf.append(cat.getLevel());
>>                buf.append("\n");
>>                buf.append(" Additivity = ");
>>                buf.append(cat.getAdditivity());
>>                buf.append("\n");
>>                Enumeration appEnum = cat.getAllAppenders();
>>                while (appEnum.hasMoreElements()) {
>>                    Appender app = (Appender) (appEnum.nextElement());
>>                    buf.append(" Appender name = ");
>>                    buf.append(app.getName());
>>                    buf.append("\n");
>>                    // may want to check the filter and the layout of the
>> appender
>>                }
>>            }
>>        }
>>        System.out.println(buf.toString());
>>    }
>>    /**
>>     * Example main() code
>>     * 2) The TTCCLayout timing info is crap --- Is this also the case in
>> UNIX?
>>     */
>>
>>    public static void main(String[] argv) {
>>        Logger logger = null;
>>        if (argv != null && argv.length >= 1 &&
>> "WITH".equalsIgnoreCase(argv[0])) {
>>            logger = Logger.getLogger(CLASS + ".main");
>>            System.out.println("WITH Logger allocated");
>>        } else {
>>            System.out.println("WITHOUT Logger allocated");
>>        }
>>        //
>>        // prepare logging
>>        //
>>        Layout layout = new TTCCLayout();
>>        Logger.getRoot().addAppender(new ConsoleAppender(layout,
>> ConsoleAppender.SYSTEM_OUT));
>>        Logger.getRoot().setLevel(Level.DEBUG);
>>        //
>>        // write out how the hierarchy looks now
>>        //
>>        listSetupOfDefaultLog4JHierarchy();
>>        //
>>        // then write some stuff
>>        //
>>        if (logger != null) {
>>            for (int i = 0; i < 10; i++) {
>>                logger.debug("This is message " + i);
>>            }
>>        }
>>    }
>> }
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>>
>
> --
> Ceki
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Re: The twilight zone? Weird interaction of log4j with jakarta POI

Posted by Ceki Gülcü <ce...@qos.ch>.
You have been bitten by #13201 which was discussed a few days ago and keeps 
rearing its ugly head.

See http://marc.theaimsgroup.com/?t=104497294500002&r=1&w=2

and in particular

http://marc.theaimsgroup.com/?l=log4j-user&m=104498017406236&w=2

To get it fixed, don't forget to vote:

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13201

At 21:04 17.02.2003 +0100, you wrote:
>Hello people.
>
>I have got a problem that got me stumped a bit (well, not really, but
>I wanted to hear what others say about it). In a word: adding
>the Jakarta POI jar to the CLASSPATH alters log4j logging behaviour
>because an appender shows up on the root Logger. Spooky.
>
>Here's more details:
>
>1) SUN JVM 1.4.1_01 on Windows 2000
>2) Jakarta Log4J comes from:  jakarta-log4j-1.2.7.jar
>3) Jakarta POI   comes from:  jakarta-poi-1.5.1-final-20020615.jar
>
>Now, I just run a little program (see below) that writes out
>the whole Log4J Hierarchy after startup. If the Jakarta POI jar is
>in the CLASSPATH, we see two additional appenders (see comments).
>This is unnerving because all the log messages show up twice on
>stdout if you happen to add your own appender to the root Logger.
>
>I did not know that adding a jar to the CLASSPATH w/o referencing
>any class contained in it would change anything. Also, there are
>no static initializers in POI...Does Log4J do anything unexpected?
>
>Just to be on the safer side of sure, I tried the stunt on Blackdown
>JVM 1.3.1 on a Linux machine. Same result.
>
>It does not happen for IBM JVM 1.2 in the VisualAge IDE, though. Hmm..
>
>So, what's going on?
>
>Best regards,
>
>         -- David Tonhofer
>
>
>-----------8<--------------------------8<--------------------------
>
>package com.mplify.win2k.diskmon;
>
>import org.apache.log4j.Appender;
>import java.util.Enumeration;
>import org.apache.log4j.Logger;
>import org.apache.log4j.Layout;
>import org.apache.log4j.Level;
>import org.apache.log4j.TTCCLayout;
>import org.apache.log4j.ConsoleAppender;
>import org.apache.log4j.LogManager;
>
>/**********************************************************************
>* Simple test of Log4J.
>* By default, the program just writes out a description of the logging
>* hierarchy to stdout using the System.out PrintStream. If the first
>* argument to the program is 'WITH', a logger is allocated before the
>* logging hierarchy is printed to stdout.
>*
>* With 'jakarta-poi' in the classpath:
>* ====================================
>*
>* WITH Logger allocated
>* LOGGER: root
>*  Level   = DEBUG                                <-- our level for root 
>(POI sets it to FATAL)
>*  Additivity = true
>*  Appender name = stdout                         <-- Jakarta-POI 
>debugging appender
>*  Appender name = null                           <-- our appender for root
>* LOGGER: com.mplify.win2k.diskmon.Log4JTest.main <-- our method-specific 
>logger
>*  Level   = null
>*  Additivity = true
>* LOGGER: org                                     <-- Jakarta-POI specific 
>logger
>*  Level   = FATAL                                <-- ...it works at level 
>FATAL
>*  Additivity = true
>*  Appender name = stdout                         <-- Jakarta-POI 
>debugging appender
>*
>* WITHOUT Logger allocated
>* LOGGER: root
>*  Level   = DEBUG                                <-- our level for root 
>(POI sets it to FATAL)
>*  Additivity = true
>*  Appender name = stdout                         <-- Jakarta-POI 
>debugging appender
>*  Appender name = null                           <-- our appender for root
>* LOGGER: org                                     <-- Jakarta-POI specific 
>logger
>*  Level   = FATAL                                <-- ...it works at level 
>FATAL
>*  Additivity = true
>*  Appender name = stdout                         <-- Jakarta-POI 
>debugging appender
>*
>* With no 'jakarta-poi' in the classpath:
>* =======================================
>*
>* WITH Logger allocated
>* LOGGER: root
>*  Level   = DEBUG                                 <-- our level for root
>*  Additivity = true
>*  Appender name = null                            <-- our appender for root
>* LOGGER: com.mplify.win2k.diskmon.Log4JTest.main  <-- our method-specific 
>logger
>*  Level   = null
>*  Additivity = true
>*
>* 20 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is message 0
>* 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is message 1
>* 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is message 2
>* 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is message 3
>* 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is message 4
>* 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is message 5
>* 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is message 6
>* 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is message 7
>* 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is message 8
>* 30 [main] DEBUG com.mplify.win2k.diskmon.Log4JTest.main - This is message 9
>*
>* WITHOUT Logger allocated
>* LOGGER: root
>*  Level   = DEBUG                                 <-- our level for root
>*  Additivity = true
>*  Appender name = null                            <-- our appender for root
>*********************************************************************/
>
>public class Log4JTest {
>
>    private final static String PACKAGE = "com.mplify.win2k.diskmon";
>    private final static String CLASS = PACKAGE + ".Log4JTest";
>
>    /**
>    * List the whole setup of Log4J's default Hierarchy
>    * Except the Renderers which are not listable
>    */
>
>    public static void listSetupOfDefaultLog4JHierarchy() {
>        StringBuffer buf = new StringBuffer();
>        //
>        // first the root element of the default hierarchy
>        //
>        {
>            Logger root = Logger.getRootLogger();
>            buf.append("LOGGER: ");
>            buf.append(root.getName());
>            buf.append("\n");
>            buf.append(" Level   = ");
>            buf.append(root.getLevel());
>            buf.append("\n");
>            buf.append(" Additivity = ");
>            buf.append(root.getAdditivity());
>            buf.append("\n");
>            Enumeration appEnum = root.getAllAppenders();
>            while (appEnum.hasMoreElements()) {
>                Appender app = (Appender) (appEnum.nextElement());
>                buf.append(" Appender name = ");
>                buf.append(app.getName());
>                buf.append("\n");
>                // may want to check the filter and the layout of the appender
>            }
>        }
>        //
>        // then for the rest of the categories
>        //
>        {
>            Enumeration enum = LogManager.getCurrentLoggers();
>            while (enum.hasMoreElements()) {
>                Logger cat = (Logger) (enum.nextElement());
>                buf.append("LOGGER: ");
>                buf.append(cat.getName());
>                buf.append("\n");
>                buf.append(" Level   = ");
>                buf.append(cat.getLevel());
>                buf.append("\n");
>                buf.append(" Additivity = ");
>                buf.append(cat.getAdditivity());
>                buf.append("\n");
>                Enumeration appEnum = cat.getAllAppenders();
>                while (appEnum.hasMoreElements()) {
>                    Appender app = (Appender) (appEnum.nextElement());
>                    buf.append(" Appender name = ");
>                    buf.append(app.getName());
>                    buf.append("\n");
>                    // may want to check the filter and the layout of the 
> appender
>                }
>            }
>        }
>        System.out.println(buf.toString());
>    }
>    /**
>     * Example main() code
>     * 2) The TTCCLayout timing info is crap --- Is this also the case in 
> UNIX?
>     */
>
>    public static void main(String[] argv) {
>        Logger logger = null;
>        if (argv != null && argv.length >= 1 && 
> "WITH".equalsIgnoreCase(argv[0])) {
>            logger = Logger.getLogger(CLASS + ".main");
>            System.out.println("WITH Logger allocated");
>        } else {
>            System.out.println("WITHOUT Logger allocated");
>        }
>        //
>        // prepare logging
>        //
>        Layout layout = new TTCCLayout();
>        Logger.getRoot().addAppender(new ConsoleAppender(layout, 
> ConsoleAppender.SYSTEM_OUT));
>        Logger.getRoot().setLevel(Level.DEBUG);
>        //
>        // write out how the hierarchy looks now
>        //
>        listSetupOfDefaultLog4JHierarchy();
>        //
>        // then write some stuff
>        //
>        if (logger != null) {
>            for (int i = 0; i < 10; i++) {
>                logger.debug("This is message " + i);
>            }
>        }
>    }
>}
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>

--
Ceki 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org