logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jay Riddell" <jridd...@doradosoftware.com>
Subject Re: Problems with Filtering Extended Categories and Priorities
Date Tue, 26 Jun 2001 21:10:50 GMT

Ummm, thanks . . but no, it didn't work.

However, when I set it to INFO it works as expected.

Does this imply that my subclass of Category or Priority is incorrect ?

My subclass of Priority (actually called com.ebss.utilities.PPCSPriority)
is included below.

(Note: besides subclassing Category & Priority, I added/modified
no other code.)

Thanks

////////////////////////////////////////////////////////////////////////////////////////////////////
/**
    Clone and hack of org.apache.log4j.xml.exmples.PPCSPriority
    from log4j 1.1.1

    Purpose is to provide the NOTIFY and the FORCELOG priorities.
*/

package com.ebss.utilities ;

import org.apache.log4j.Priority;


/**
   This class introduces a new priority level called NOTIFY.
        - It will use a different appender.

   This class introduces a new priority level called FORCELOG.
        - It's output will NEVER be masked.

 */
public class PPCSPriority extends Priority {

  static final int  NOTIFY_INT     = Priority.FATAL_INT + 1;
  static final int  FORCELOG_INT   = Priority.FATAL_INT + 2;

  private static String NOTIFY_STR    = "NOTIFY";
  private static String FORCELOG_STR  = "FORCELOG";

  public static final PPCSPriority NOTIFY   = new PPCSPriority(NOTIFY_INT,   NOTIFY_STR, 5);
  public static final PPCSPriority FORCELOG = new PPCSPriority(FORCELOG_INT, FORCELOG_STR,
5);

  protected
  PPCSPriority(int level, String strLevel, int syslogEquiv) {
    super(level, strLevel, syslogEquiv);
  }
  public
  static
  Priority toPriority(String sArg, Priority defaultValue) {

    if(sArg == null) {
      return defaultValue;
    }
    String stringVal = sArg.toUpperCase();

    if(stringVal.equals(NOTIFY_STR)) {
      return PPCSPriority.NOTIFY;
    } else if(stringVal.equals(FORCELOG_STR)) {
      return PPCSPriority.FORCELOG;
    }

    return Priority.toPriority(sArg, defaultValue);
  }
  public
  static
  Priority toPriority(int i) throws  IllegalArgumentException {
    switch(i) {
    case NOTIFY_INT:   return PPCSPriority.NOTIFY;
    case FORCELOG_INT: return PPCSPriority.FORCELOG;
    }
    return Priority.toPriority(i);
  }
}
////////////////////////////////////////////////////////////////////////////////////////////////////

----- Original Message -----
From: "Ceki Gülcü" <cgu@qos.ch>
To: "LOG4J Users Mailing List" <log4j-user@jakarta.apache.org>
Sent: Tuesday, June 26, 2001 1:05 PM
Subject: Re: Problems with Filtering Extended Categories and Priorities



Jay,

Try <param name="PriorityToMatch" value="NOTIFY#your.Priority.subclass" />



At 12:01 26.06.2001 -0700, you wrote:
>I have extended Category (MyNewCategory) and have created 2
>of my own priorities (NOTIFY and FORCELOG).
>
>I am using XML properties/config files.
>
>I can successfully filter (or set the logging priority) per class (aka category)
>using the following:
>   <category name="a.b.c.d" class="MyNewCategory">
>        <priority value="NOTIFY" />
>    </category>
>
>However, the purpose for my NOTIFY priority was to separately filter
>that and write it to a NT Event Log Appender.  For now, I am using a
>FileAppender to write these events to a separate log file.
>
>I have this appender configured as follows:
>
>    <!--  Define the NOTIFY_TO_LOG appender -->
>    <appender name="NOTIFY_TO_LOG" class="org.apache.log4j.FileAppender">
>       <param name="File" value="log_notification_out.txt"/>
>
>        <layout class="org.apache.log4j.PatternLayout">
>            <param name="ConversionPattern" value="%d{ISO8601} XXXX: %m%n"/>
>        </layout>
>
> <!-- Only write events with Priority=NOTIFY to this appender -->
>        <filter class="org.apache.log4j.varia.PriorityMatchFilter">
>            <param name="PriorityToMatch" value="NOTIFY" />
>            <param name="AcceptOnMatch" value="true" />
>        </filter>
>        <filter class="org.apache.log4j.varia.DenyAllFilter">
>        </filter>
>    </appender>
>
>If I change the PriorityToMatch value to INFO, then I get all my INFO logs
>to go to this file using the format specified in the ConversionPattern.
>Therefore, I suspect that my XML is setup properly.
>
>Inspection of org.apache.log4j.spi.LoggingEvent.java shows that it says
>"  <p>This class is of concern to those wishing to extend log4j. ".
>
>However, I am at a loss to understand how I should proceed.
>
>1) Should I *modify* the file and change all usages of Category to MyNewCategory ?
>Would then I need to modify all the caller's to pass in a MyNewCategory ?
>
>2) Should I attempt to check if the given category object is really a MyNewCategory object
?
>
>3) Or more likely, I have no real clue !! <grin>
>
>Any and all help would be appreciated.
>
>Thanks
>
>
>
>----------------------------------------------------------------
>Jay Riddell
>Dorado Software
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org

--
Ceki Gülcü


---------------------------------------------------------------------
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


Mime
View raw message