Specifications
CHAPTER 11
234
The logging API consists of the following parts:
Logger The logger provides an interface for sending a message to an active target. Loggers implement the ILogger
interface and call methods on the Log class. The two classes of information used to filter a message are category
and level. Each logger operates under a category. A category is a string used to filter all messages sent from that
logger. For example, a logger can be acquired with the category “orange”. Any message sent using the “orange”
logger only reaches those targets that are listening for the “orange” category. In contrast to the category that is
applied to all messages sent with a logger, the level provides additional filtering on a per-message basis. For
example, to indicate that an error occurred within the “orange” subsystem, you can use the error level when
logging the message. The supported levels are defined by the LogEventLevel class. The Flex framework classes that
use the logging API set the category to the fully qualified class name as a convention.
Log target The log target defines where log messages are written. Flex predefines a single log target: Tra ceTarget,
which is the most commonly used log target. This log target connects the logging API to the trace system so that
log messages are sent to the same location as the output of the
trace() method. For more information on the
trace() method, see “Using the global trace() method” on page 232.
You can also write your own custom log target. For more information, see “Implementing a custom logger with
the logging API” on page 238.
Destination The destination is where the log message is written. Typically, this is a file, but it can also be a console
or something else, such as an in-memory object. The default destination for TraceTarget is the flashlog.txt file. You
configure this destination on the client.
The following example shows a sample relationship between a logger, a log target, and a destination:
You can also use the logging API to send messages from custom code you write. You can do this when you create
a set of custom APIs or components or when you extend the Flex framework classes and you want users to be able
to customize their logging. For more information, see “Implementing a custom logger with the logging API” on
page 238.
The following packages within the Flex framework are the only ones that use the logging API:
• mx.rpc.*
• mx.messaging.*
• mx.data.*
To configure client-side logging in MXML or ActionScript, create a TraceTarget object to log messages. The Trace-
Target object logs messages to the same location as the output of the
trace() statements. You can also use the
TraceTarget to specify which classes to log messages for, and what level of messages to log.
ashlog.txt
Destination
TraceTarget
Log target
ILogger
Logger










