注意:后代必须覆盖此方法才能使其发挥作用。
每个记录器都属于一个类别。一般而言,这些类别将映射到使用记录器的 fully-qualified 类名称。例如,记录
例如:
var traceLogger:ILoggingTarget = new TraceTarget(); traceLogger.filters = ["mx.rpc.~~", "mx.messaging.~~"]; Log.addTarget(traceLogger);
注意:此方法由框架调用,您不应该进行直接调用。
注意:此方法由框架调用,您不应该进行直接调用。
每个记录器都属于一个类别。一般而言,这些类别将映射到使用记录器的完全限定类名称。例如,记录
var traceLogger:ILoggingTarget = new TraceTarget(); traceLogger.filters = [ "mx.rpc.~~", "mx.messaging.~~" ]; Log.addTarget(traceLogger);
为日志记录指定的字符串可以包含使用括号括起来的索引,用于指示在记录字符串之前应该插入哪个附加参数。例如,当使用 10 和 15 作为参数进行调用时,“第一个附加参数是 {0},第二个附加参数是 {1}”将转化为“第一个附加参数是 10,第二个附加参数是 15”。
// Get the logger for the mx.messaging.Channel "category" // and send some data to it. var logger:ILogger = Log.getLogger("mx.messaging.Channel"); logger.debug("here is some channel info {0} and {1}", 15.4, true); // This will log the following String: // "here is some channel info 15.4 and true"
为日志记录指定的字符串可以包含使用括号括起来的索引,用于指示在记录字符串之前应该插入哪个附加参数。例如,当使用 10 和 15 作为参数进行调用时,“第一个附加参数是 {0},第二个附加参数是 {1}”将转化为“第一个附加参数是 10,第二个附加参数是 15”。
// Get the logger for the mx.messaging.Channel "category" // and send some data to it. var logger:ILogger = Log.getLogger("mx.messaging.Channel"); logger.error("here is some channel info {0} and {1}", 15.4, true); // This will log the following String: // "here is some channel info 15.4 and true"
为日志记录指定的字符串可以包含使用括号括起来的索引,用于指示在记录字符串之前应该插入哪个附加参数。例如,当使用 10 和 15 作为参数进行调用时,“第一个附加参数是 {0},第二个附加参数是 {1}”将转化为“第一个附加参数是 10,第二个附加参数是 15”。
// Get the logger for the mx.messaging.Channel "category" // and send some data to it. var logger:ILogger = Log.getLogger("mx.messaging.Channel"); logger.fatal("here is some channel info {0} and {1}", 15.4, true); // This will log the following String: // "here is some channel info 15.4 and true"
为日志记录指定的字符串可以包含使用括号括起来的索引,用于指示在记录字符串之前应该插入哪个附加参数。例如,当使用 10 和 15 作为参数进行调用时,“第一个附加参数是 {0},第二个附加参数是 {1}”将转化为“第一个附加参数是 10,第二个附加参数是 15”。
// Get the logger for the mx.messaging.Channel "category" // and send some data to it. var logger:ILogger = Log.getLogger("mx.messaging.Channel"); logger.info("here is some channel info {0} and {1}", 15.4, true); // This will log the following String: // "here is some channel info 15.4 and true"
为日志记录指定的 String 可以包含使用括号括起来的索引,用于指示在记录 String 之前应该插入哪个附加参数。例如,当使用 10 和 15 作为参数进行调用时,“第一个附加参数是 {0},第二个附加参数是 {1}”将转化为“第一个附加参数是 10,第二个附加参数是 15”。
// Get the logger for the mx.messaging.Channel "category" // and send some data to it. var logger:ILogger = Log.getLogger("mx.messaging.Channel"); logger.log(LogEventLevel.DEBUG, "here is some channel info {0} and {1}", LogEventLevel.DEBUG, 15.4, true); // This will log the following String as a DEBUG log message: // "here is some channel info 15.4 and true"
为日志记录指定的字符串可以包含使用括号括起来的索引,用于指示在记录字符串之前应该插入哪个附加参数。例如,当使用 10 和 15 作为参数进行调用时,“第一个附加参数是 {0},第二个附加参数是 {1}”将转化为“第一个附加参数是 10,第二个附加参数是 15”。
// Get the logger for the mx.messaging.Channel "category" // and send some data to it. var logger:ILogger = Log.getLogger("mx.messaging.Channel"); logger.warn("here is some channel info {0} and {1}", 15.4, true); // This will log the following String: // "here is some channel info 15.4 and true"
记录器是为特殊类别的信息创建的 singleton 实例。通常,类别是希望记录信息的组件的包名称。通过类别,用户可以指定自己感兴趣的日志信息。您可以选择多个类别并使用正则表达式将其合并。这样可以扩大或缩小获取的日志记录信息的范围。例如,您也许对“mx.messaging”和“mx.rpc”包下的所有日志信息感兴趣,并希望这些包中的内容的输出格式为 XML。要获得“mx.messaging”类别(包括子包和组件)下的所有日志信息,则需要通配符表达式,如“mx.messaging.~~”。有关更多详细信息,请参阅下文中的代码示例。
目标提供记录的数据的输出机制。此机制通常包括格式设置、传输或存储,但可以是 VM 下的任何内容。提供了两个目标:
... 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); } ...
为日志记录指定的字符串可以包含使用括号括起来的索引,用于指示在记录字符串之前应该插入哪个附加参数。例如,当使用 10 和 15 作为参数进行调用时,“第一个附加参数是 {0},第二个附加参数是 {1}”将转化为“第一个附加参数是 10,第二个附加参数是 15”。
为日志记录指定的字符串可以包含使用括号括起来的索引,用于指示在记录字符串之前应该插入哪个附加参数。例如,当使用 10 和 15 作为参数进行调用时,“第一个附加参数是 {0},第二个附加参数是 {1}”将转化为“第一个附加参数是 10,第二个附加参数是 15”。
为日志记录指定的字符串可以包含使用括号括起来的索引,用于指示在记录字符串之前应该插入哪个附加参数。例如,当使用 10 和 15 作为参数进行调用时,“第一个附加参数是 {0},第二个附加参数是 {1}”将转化为“第一个附加参数是 10,第二个附加参数是 15”。
为日志记录指定的字符串可以包含使用括号括起来的索引,用于指示在记录字符串之前应该插入哪个附加参数。例如,当使用 10 和 15 作为参数进行调用时,“第一个附加参数是 {0},第二个附加参数是 {1}”将转化为“第一个附加参数是 10,第二个附加参数是 15”。
为日志记录指定的 String 可以包含使用括号括起来的索引,用于指示在记录 String 之前应该插入哪个附加参数。例如,当使用 10 和 15 作为参数进行调用时,“第一个附加参数是 {0},第二个附加参数是 {1}”将转化为“第一个附加参数是 10,第二个附加参数是 15”。
为日志记录指定的字符串可以包含使用括号括起来的索引,用于指示在记录字符串之前应该插入哪个附加参数。例如,当使用 10 和 15 作为参数进行调用时,“第一个附加参数是 {0},第二个附加参数是 {1}”将转化为“第一个附加参数是 10,第二个附加参数是 15”。