You need to let your Logger (why are you using the deprecated Category
class?) that it needs to use at least TRACE level.

I've updated the Wiki page.


-----Original Message-----
From: David Siegel [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 19, 2003 3:57 PM
To: Log4J Developers List
Subject: RE: Custom Log Level Example(s)



Thanks Jim,

I created a class using this example, but cannot get the output to show. I 
get all levels but the TRACE level. Can anyone point out what I am doing 
wrong please?

Thanks

The test class:

import org.apache.log4j.*;

public class TestLogging {

     // Initialize a logging category.  Here, we get THE ROOT CATEGORY
     //static Category cat = Category.getRoot();
     // Or, get a custom category
     static Category cat =
Category.getInstance(TestLogging.class.getName());

     public static void main(String args[]) {
         // Try a few logging methods
                 cat.setAdditivity(true); //--> Will append
         cat.debug("Start of main()");
                 cat.log(TraceLevel.TRACE, "Got here");
         cat.info("Testing a log message with priority set to INFO");
         cat.warn("Testing a log message with priority set to WARN");
         cat.error("Testing a log message with priority set to ERROR");
         cat.fatal("Testing a log message with priority set to FATAL");
                 cat.log(Level.ERROR, "Test ERROR message");

         new TestLogging().init();
     }

     public void init() {
         java.util.Properties prop = System.getProperties();
         java.util.Enumeration enum = prop.propertyNames();

         cat.info("***System Environment As Seen By Java***");
         cat.debug("***Format: PROPERTY = VALUE***");

         while (enum.hasMoreElements()) {
             String key = (String) enum.nextElement();
             cat.info(key + " = " + System.getProperty(key));
         }
     }

}


The config file:
#### Use two appenders, one to log to console, another to log to a file
log4j.rootCategory=DEBUG, stdout, R

# Print only messages of priority WARN or higher for your category
log4j.category.your.category.name=DEBUG

#### First appender writes to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout


# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

#### Second appender writes to a file
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=example.log

# Control the maximum log file size log4j.appender.R.MaxFileSize=100KB
log4j.appender.R.MaxBackupIndex=1

log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n


At 01:14 PM 3/19/2003 -0500, Jim Moore wrote:
>http://nagoya.apache.org/wiki/apachewiki.cgi?Log4JProjectPages/TraceLev
>el
>


*********************************************
David Siegel
GIS Developer
Harvard University
Office for Information Systems

The Harvard Geospatial Library:  http://hgl.harvard.edu
*********************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to