Messager Logging Configuration
Logging behaviors of Message Facility Messager s are configured by MetaBundle s having the same name. Default Messager s are configured by default MetaBundle s.
Look at this meta resource file (tutor/msg.meta):
<?xml version="1.0" encoding="UTF-8"?> <java> <messaging revealLocation="false" /> <logging level="CONFIG"> <formatters> <xml class="java.util.logging.XMLFormatter" /> </formatters> <handlers> <msg-xml encoding="UTF-8" level="ALL" class="av.msg.logging.FileHandler"> <formatter>xml</formatter> <property name="append" value="true" /> <property name="file" value="%h/msglog%u.xml" /> <property name="autoFlush" value="true" /> </msg-xml> </handlers> <handler>console</handler> <handler>msg-xml</handler> </logging> </java>This snippet is from tutor/msg.meta
It configures Messager tutor.msg, and provides the default
configuration for all its descendants.
And one of its descendants - Messager tutor.msg.Reuse, is
just configured to override the logging level by meta resource tutor/msg/Reuse.meta
<?xml version="1.0" encoding="UTF-8"?> <java> <messaging revealLocation="false" /> <logging level="ALL" /> </java>This snippet is from tutor/msg/Reuse.meta
These meta resources (XML files) will just take effect when you put them on your Java Classpath.
The configuration format is somewhat self-explaining:
logging/formatters.
The node name will turn out to be the formatter name, used to reference it by
handler definitions. And you need to specify its Java class name with the @class
attribute. Extra nested <property name="xxx" value="xxx"
/> elements can be supplied as well as for the handlers. These properties
will be interpreted as Bean Properties and writen to the constructed
formatter instance.
logging/handlers.
The node name will turn out to be the handler name, used to reference it by
Messager handler lists. You need to supply the handler's Java class name with
the @class attribute. And @encoding and @level
are optional if you want specific values rather than defaults. Nested <property
name="xxx" value="xxx" /> elements can be supplied, as Bean Properties to
be writen to the constructed handler instance.
handler
elements under logging, as their text content referencing
defined handlers via name. The referenced handlers can either be defined
within the same meta resource, or defined in any of its ancestors.
As you may guess, the <handler>console</handler>
is referencing a handler defined in the meta resource provided by Message
Facility that for all messagers.
<?xml version="1.0" encoding="UTF-8"?> <java> <messaging revealLocation="false" /> <logging level="CONFIG"> <formatters> <simple class="java.util.logging.SimpleFormatter" /> </formatters> <handlers> <console class="java.util.logging.ConsoleHandler" level="ALL"> <formatter>simple</formatter> </console> </handlers> <handler>console</handler> </logging> </java>This snippet is from
default.metaextracted from av6base.jar.