| Building and Deploying Flex 2 Applications > Building Flex Applications > Logging > Client-side logging and debugging > Using the Logging API > Using the Logging API with data services | |||
The data services classes are designed to use the Logging API to log client-side and server-side messages.
level property of the log target. You can also add detail to the log file output, such as the date and time that the event occurred, by using properties of the log target. addTarget() method to add the new target to the logging system. Calling the addTarget() method is not required when you create a target in MXML. As long as the client is using the debugger version of Flash Player and meets the requirements described in Configuring the debugger version of Flash Player to record trace() output, the messages are logged.The following example configures a TraceTarget logging target in ActionScript:
Revised 09/27/2006: Fixed logTarget variable declaration.
<!-- Logging configured in ActionScript. -->
<mx:Script><![CDATA[
import mx.logging.targets.*;
import mx.logging.*;
private function initLogging():void {
// Create a target.
var logTarget:TraceTarget = new TraceTarget();
// Log only messages for the classes in the mx.rpc.* and
// mx.messaging packages.
logTarget.filters=["mx.rpc.*","mx.messaging.*"];
// Log all log levels.
logTarget.level = LogEventLevel.ALL;
// Add date, time, category, and log level to the output.
logTarget.includeDate = true;
logTarget.includeTime = true;
logTarget.includeCategory = true;
logTarget.includeLevel = true;
// Begin logging.
Log.addTarget(logTarget);
}
]]></mx:Script>
In the preceding example, the filters property is set to log messages for all classes in the mx.rpc and mx.messaging packages.
You can also configure a log target in MXML. When you do this, though, you must be sure to use an appropriate int (such as 2) rather than a constant (such as DEBUG). The following example sets the values of the filters for a TraceTarget logging target by using MXML syntax:
<!-- Logging configured in MXML. -->
<mx:TraceTarget>
<mx:filters>
<mx:Array>
<mx:String>mx.data.DataService</mx:String>
<mx:String>mx.data.ConflictResolver</mx:String>
</mx:Array>
</mx:filters>
<!-- 2 is represents the LogEventLevel.DEBUG constant. -->
<mx:level>2</mx:level>
</mx:TraceTarget>
In the preceding example, the TraceTarget logging target logs messages for the DataService, and ConflictResolver classes in the mx.data package.
Flex 2
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flex/2/docs/00001534.html