Specifications

241ADOBE FLEX 3
Building and Deploying Adobe Flex 3 Applications
The previous example logs messages dispatched from any category because the TraceTargets filters property is
set to the wildcard character (*). The framework code sets the category of the logger to the fully qualified class
name of the class in which logging is being performed. This is by convention only; any String specified when
calling
Log.getLogger(x) is the category required in a filters property to receive the message.
When you set the
filters property for logging within the Flex framework, you can restrict this to a certain
package or packages, or to other classes. To restrict the logging to your custom class only, add the category
specified when the logger was acquired (“MyCustomLogger”) to the
filters Array, as the following example
shows:
<mx:filters>
<mx:Array>
<mx:String>MyCustomLogger</mx:String>
</mx:Array>
</mx:filters>
In ActionScript, you can set the filters property by using the following syntax:
traceTarget.filters = ["p1.*", "p2.*", "otherPackage*"];
The wildcard character can appear only at the end of a value in the Array.
The
Log.getLogger() method sets the category of the logger. You pass this method a String that defines the
category.
Note: The Flex packages that use the logging API set the category to the current class name by convention, but it can
be any String that falls within the filters definitions.
The value of the category must fall within the definition of at least one of the filters for the log message to be
logged. For example, if you set the
filters property to something other than “*” and you use
Log.getLogger("MyCustomLogger"), the filter Array must include an entry that matches MyCustomLogger,
such as “MyCustomLogger” or “My*”.
You can include the loggers category in your log message, if you set the logger’s
includeCategory property to
true.
You can also use the ILogger interfaces
log() method to customize the log message, and you can specify the
logging level in that method. The following example logs messages that use the log level that is passed into the
method:
package { // The empty package.
// logging/MyCustomLogger2.as
import mx.controls.Button;
import flash.events.*;
import flash.events.MouseEvent;
import mx.logging.*;
import mx.logging.targets.*;