Using Flex Log instead of trace()

1 view
Skip to first unread message

vrathore

unread,
Aug 9, 2008, 2:37:40 AM8/9/08
to Delhi Flex User Group
Here is a sample code for using Log Class for flex

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);
}

will agree with the saying, “Old habits die hard”, but when I started
using the Flex logging classes, it wasn’t a difficult transition at
all. If you’re an old Flash Developer turned Flex, I strongly urge you
to check out the Flex Logging classes!

Cheers

Varun Rathore
Reply all
Reply to author
Forward
0 new messages