Syslog: White Paper FAQ Examples JavaDoc
Protomatter Classes v1.1.6

com.protomatter.syslog
Class JDK14PerChannelPolicy

java.lang.Object
  |
  +--com.protomatter.syslog.SimpleLogPolicy
        |
        +--com.protomatter.syslog.JDK14PerChannelPolicy
All Implemented Interfaces:
LogPolicy

public class JDK14PerChannelPolicy
extends SimpleLogPolicy

A policy that can make decision on a per-channel basis. It maintains a default log mask and channel list itself, but also has a list of "policy groups" that each have a log mask and channel list of their own in addition to a list of channel names that their mask and channel list applies to. If a message coming from a channel in one of those lists matches the mask and channel list, the message is logged. If not, but the message severity and channel match the default mask and channel list, it is also logged. Otherwise, the message is ignored.

This policy can be used to effectively say that messages from channels A and B should be logged if their severity is WARNING or greater, and that messages from channels C and D should be logged if their severity is INFO or greater and on a certain set of channels and that if all else fails, messages at or above the INFO level will be logged. It's very configurable.

Each "channel name" is actually a regular expression, so you can match things like "com.protomatter.syslog.*" and other stuff. This functionality uses the java.util.regex package from JDK 1.4.

See Also:
XML configuration class

Inner Class Summary
static class JDK14PerChannelPolicy.PolicyGroup
          A policy within a policy -- this is exactly like the SimpleLogPolicy except that it also checks to see if the channel issuing the log message is in some set.
 
Constructor Summary
JDK14PerChannelPolicy()
          Default constructor.
 
Method Summary
 void addPolicyGroup(JDK14PerChannelPolicy.PolicyGroup group)
          Add a policy group to our list.
 java.util.List getGroupList()
          Get the list of policy groups.
 java.util.Iterator getPolicyGroups()
          Get the list of policy groups.
 void removePolicyGroup(JDK14PerChannelPolicy.PolicyGroup group)
          Remove a policy group from our list.
 void setGroupList(java.util.List list)
          Set the list of policy groups.
 boolean shouldLog(SyslogMessage message)
          Decide if the message should be logged.
 
Methods inherited from class com.protomatter.syslog.SimpleLogPolicy
addChannel, getChannels, getLogMask, getName, inMask, removeAllChannels, removeChannel, setChannels, setChannels, setLogMask, setLogMask, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDK14PerChannelPolicy

public JDK14PerChannelPolicy()
Default constructor.
Method Detail

getGroupList

public java.util.List getGroupList()
Get the list of policy groups.

setGroupList

public void setGroupList(java.util.List list)
Set the list of policy groups.

shouldLog

public boolean shouldLog(SyslogMessage message)
Decide if the message should be logged. Each policy group is asked if it should be logged, and if none of them say yes, then we defer to our superclass. Each policy group maintains a channel list, log mask and a set of channel names -- to decide if it should log the message, the policy group first checks the message's severity and channel against its log mask and channel list. If it passes this test, the policy group checks to see if the channel name of the logger is in it's list.
Overrides:
shouldLog in class SimpleLogPolicy

getPolicyGroups

public java.util.Iterator getPolicyGroups()
Get the list of policy groups.

addPolicyGroup

public void addPolicyGroup(JDK14PerChannelPolicy.PolicyGroup group)
Add a policy group to our list.

removePolicyGroup

public void removePolicyGroup(JDK14PerChannelPolicy.PolicyGroup group)
Remove a policy group from our list.

Protomatter Classes v1.1.6
Copyright 1998-2001 Nate Sammons

Protomatter Classes v1.1.6 http://protomatter.sourceforge.net/1.1.6