com.protomatter.syslog.xml
Class PerClassPolicy_Helper
java.lang.Object
|
+--com.protomatter.syslog.xml.SimpleLogPolicy_Helper
|
+--com.protomatter.syslog.xml.PerClassPolicy_Helper
- All Implemented Interfaces:
- XMLConfigHelper
- public class PerClassPolicy_Helper
- extends SimpleLogPolicy_Helper
XML configuration helper for PerClassPolicy.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PerClassPolicy_Helper
public PerClassPolicy_Helper()
configure
public void configure(java.lang.Object o,
org.jdom.Element e)
throws SyslogInitException
- Configure this policy given the XML element.
This class inherits the policy element parameters
that
SimpleLogPolicy_Helper
understands. The additional Policy elements should
look like this:
<Policy class="com.protomatter.syslog.PerClassPolicy" >
<!--
Config params from SimpleLogPolicy_Helper can
get inserted here.
-->
<PolicyGroup>
<!--
Config params from SimpleLogPolicy_Helper can
get inserted here.
-->
<classPattern>ClassPattern-1</classPattern>
<classPattern>ClassPattern-2</classPattern>
...
<classPattern>ClassPattern-N</classPattern>
<className>ClassName-1</className>
<className>ClassName-2</className>
...
<className>ClassName-N</className>
</PolicyGroup>
<!-- Insert more PolicyGroups here -->
</Policy>
|
This class basically reads each <PolicyGroup>
element and creates a new PolicyGroup
instance and
configures that instance with the <PolicyGroup>
element.
If none of the pattern groups has anything to say about
logging the message, the decision is deferred to the
superclass
and it makes the
decision based on the log mask and channel information
that was defined in the enclosing Policy element.
Element |
name |
value |
required |
PolicyGroup |
See PolicyGroup docs. |
no |
The following example should explain things better:
<Policy class="com.protomatter.syslog.PerClassPolicy" >
<!--
Defaults -- if none of the groups below match,
then only allow messages at or above the WARNING level.
-->
<logMask>WARNING</logMask>
<channels>ALL_CHANNEL</channels>
<!--
Log DEBUG and above messages for messages coming from
the com.protomatter.xml.* and com.protomatter.jdbc.*
packages, and from the com.protomatter.util.Mutex class.
-->
<PolicyGroup>
<logMask>DEBUG</logMask>
<channels>ALL_CHANNEL</channels>
<classPattern>com.protomatter.xml.*</classPattern>
<classPattern>com.protomatter.jdbc.*</classPattern>
<className>com.protomatter.util.Mutex</className>
</PolicyGroup>
<!--
Log INFO and above messages for messages coming from
the com.protomatter.pas.* and com.protomatter.util.*
packages, and from the com.protomatter.jdbc.pool.JdbcConnectionPool class.
-->
<PolicyGroup>
<logMask>INFO</logMask>
<channels>ALL_CHANNEL</channels>
<classPattern>com.protomatter.pas.*</classPattern>
<classPattern>com.protomatter.util.*</classPattern>
<className>com.protomatter.jdbc.pool.JdbcConnectionPool</className>
</PolicyGroup>
<!--
Getting fancy now. If the channel is OPS_CHANNEL or DEV_CHANNEL
and the class name contains the word "Debug" then allow
messages at or above the ERROR level.
-->
<PolicyGroup>
<logMask>ERROR</logMask>
<channels>OPS_CHANNEL, DEV_CHANNEL</channels>
<classPattern>*Debug*</classPattern>
</PolicyGroup>
</Policy>
|
- Overrides:
configure
in class SimpleLogPolicy_Helper
configureGroup
public void configureGroup(PerClassPolicy.PolicyGroup g,
org.jdom.Element e)
throws SyslogInitException
getConfiguration
public org.jdom.Element getConfiguration(java.lang.Object o,
org.jdom.Element element)
- Description copied from interface:
XMLConfigHelper
- Encode the given object's configuration into the
given XML element.
- Overrides:
getConfiguration
in class SimpleLogPolicy_Helper
getConfigurationGroup
public org.jdom.Element getConfigurationGroup(PerClassPolicy.PolicyGroup g,
org.jdom.Element element)