The trace provided by Flex has the advantages of classification, but it is not easy to use.
<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml"
Initialize = "initializehandler ()">
<Mx: SCRIPT>
<! [CDATA [
Import MX. Logging. log;
Import mx.logging.tar gets. TraceTarget;
Import MX. Logging. logeventlevel
Private VaR _ target: TraceTarget;
Private function initializehandler (): void
{
_ Target = new TraceTarget (); // creates a trace target
_ Target. includedate = true; // display date
_ Target. parse Detime = true; // display the trace time.
_ Target. Warn delevel = true; // display level (error, debug, info .....)
_ Target. includecategory = true; // display type
_ Target. Filters = ["net. nshen. Logging. *"]; // only displays trace information in the net. nshen. Logging package.
_ Target. Level = logeventlevel. info // only Info () information is displayed. Other debug () and error () information is not displayed...
Log. addtarget (_ target); // configure the target and fill it in the log.
Log. addtarget (
}
// Trace when the button is release
Private function sendtolog (): void
{
Log. getlogger ("net. nshen. Logging. mainclass"). Info ("Check the info information ~~ Haha only shows me ");
Log. getlogger ("com. Adobe. mainclass"). Info ("because it is not in the net. nshen. Logging package, I am not shown... 5555 ");
Log. getlogger ("net. nshen. Logging. mainclass"). debug ("because it is not info information, I am not shown... 555555555555 ");
// Two parameters (type and output information)
// Of course, you can not use the full name of the class, but it will be troublesome to filter, therefore, it is better to set the category to the full name of the class, such as the net. nshen. logging. mainclass
}
]>
</MX: SCRIPT>
<Mx: button click = "sendtolog ()" label = "Log message"/>
</MX: Application>