Flex日志 logging API

 

 

Using logging API

http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7f0f.html

 

需要在Application里创建log target,通过Log.addTarget()添加到日志系统。

Flex提供了一个TraceTarget实现,通过调用trace()记录日志。

 

示例代码:

 

<?xml version="1.0"?> <!-- logging/ActionScriptTraceTarget.mxml --> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="initLogging();" height="600"> <s:layout> <s:VerticalLayout/> </s:layout> <fx:Script> <!--[CDATA[ import mx.collections.ArrayCollection; import mx.logging.targets.*; import mx.logging.*; [Bindable] public var myData:ArrayCollection; 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); } ]]--> </fx:Script> <fx:Declarations> <!-- HTTPService is in the mx.rpc.http.* package --> <mx:HTTPService id="srv" url="../assets/trace_example_data.xml" useProxy="false" result="myData=ArrayCollection(srv.lastResult.data.result)"/> </fx:Declarations> <mx:LineChart id="chart" dataProvider="{myData}" showDataTips="true"> <mx:horizontalAxis> <mx:CategoryAxis categoryField="month"/> </mx:horizontalAxis> <mx:series> <mx:LineSeries yField="apple" name="Apple"/> <mx:LineSeries yField="orange" name="Orange"/> <mx:LineSeries yField="banana" name="Banana"/> </mx:series> </mx:LineChart> <s:Button id="b1" click="srv.send();" label="Load Data"/> </s:Application>

 

 

你可能感兴趣的:(Flex,layout,application,import,logging,library)