The formatter and organizing the outputter
Now that the parser has yielded properties and values, the new data must be assembled into a CBE instance. That's the role of the formatter.
Emit CBE XML records to a file
The adapter formatter requires no configuration. It's an internal operation that creates CBE objects that conform to the CBE V1.0.1 specification.
After the formatter has created CBE objects, it's the job of the outputter to emit them to a file, standard output, another log, a logging agent, or a log analyzer. If your adapter configuration defines multiple contexts, you can use a special formatter to allow multiple contexts to write to a single file.
To keep things simple, emit the CBE XML records to a single file:
- Click Outputter in the Generic Log Adapter perspective, then choose
SingleFileOutputterfor Outputter type. - Right-click Outputter, then click Add > property.
- Click the new property, then set Property name to
directory. Set the Property value to a directory to which you're able to write files. Omit the name of a file. Just specify the path of the directory, omitting the trailing slash. - Right-click Outputter again and click Add > property. Set this new Property name to
fileName, and set the Property value to a file name. This file will be created in the directory named by directory.
In addition to changing the configuration, you must also change the context instance to use the proper outputter class. To do so, complete these steps:
- Expand Contexts in the General Log Adapter perspective and expand Context Basic Context Implementation.
- Click Component Logging Agent Outputter.
- Change the Name and Description to
Single File Outputter. - Change the Executable class to
org.eclipse.hyades.logging.adapter.outputters.CBEFileOutputter. - Save the configuration file.
Add the SingleFileOutputterType
There is one more important step: For some reason, the Adapter Configuration Editor can omit an important element from the outputter definition in the configuration file for the adapter. (You can read the relevant thread on the developerWorks Autonomic computing forum's No Output from Outputter.) However, you can quickly add the element to the file manually.
Using your favorite editor, open the file my.adapter. Scroll to the bottom of the file and look for the following text.
Listing 16. The CBE equivalent of the first record of daemon.log
<cc:Outputter
description="Single File Outputter"
uniqueID="N13725210AFF11DA8000AE8373D52828"
type="SingleFileOutputter">
<pu:Property propertyName="directory"
propertyValue="/home/mstreicher"/>
<pu:Property propertyName="fileName"
propertyValue="emitter.log"/>
<op:SingleFileOutputterType directory="/home/mstreicher"
fileName="emitter.log"/>
</cc:Outputter>
|
If the line <op:SingleFileOutputterType... /> is missing, add it, changing the values of attributes directory and fileName to match the values of the similarly names properties. Then save the file.



