Configuring the Monitor Framework
Fabric3 uses SCA eventing for monitoring runtime and application events. Runtimes are configured with two channels by default, the RuntimeMonitorChannel where runtime events are sent and the ApplicationMonitorChannel where end-user components send events. Each channel is configured by default with a consumer that listens to events and logs them using LogBack. This eventing architecture provides flexibility by allowing custom listeners to be added to the default channels for reacting to particular events. In addition, new channels can be added as destinations for custom events.
Enabling and using monitoring in applications is covered in Consuming Monitor Events. This section covers administrative and operational aspects of the Fabric3 monitor framework.
LogBack can be configured to change the log appender and format of log messages. By default, Fabric3 sends log messages to the console. Production systems should use a form of persistent logging such as the LogBack RollingFileAppender
(for documentation on available appenders, see LogBack Appenders):
Code Block | ||||
---|---|---|---|---|
| ||||
<application.monitor>
<configuration>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>fabric3.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>test.%i.log.zip</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>3</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>5MB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>[%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
</configuration>
</application.monitor>
|
Note file names specified in logback config using the <file> tag will be expanded to files under the runtime /data directory
Dynamically Changing Monitoring Levels
Fabric3 provides the ability to dynamically adjust monitoring levels using the MonitorService
service via the Management Resource Framework (MRF) or JMX. The MRF address is http://<server address>:port/management/runtime/monitor
. Values may be read using HTTP GET and changed using HTTP POST. Valid levels are:
- SEVERE - Errors encountered by the runtime or an application
- WARN - Denote an event that may potentially lead to an error or incorrect operation.
- INFO - Informational messages
- DEBUG - Used for debugging events
Monitoring levels can be adjusted for a component or deployable composite. Since components are hierarchical, setting a parent component will recursively propagate to child components. For example, given a component hierarchy of domain://foo/bar/baz
, setting the monitor level for domain://foo/bar
will also set the monitor level for domain://foo/bar/baz
. To set the monitor level of all application components, use the following URI: <domain name>://
. Similarly, to sett the monitor level for all runtime components, use the URI: fabric3://
.
HTTP Request Logging
The Fabric3 embedded Jetty HTTP server can be configured to log access using the log child element of web.server in systemConfig. Log configuration follows the NCSA format. Configuration options are shown in the following example:
...
The @file attribute configures the log file name, which is placed under the runtimes/<runtime name>/data/log
directory.