//richinternet.blog

Viewing By Entry / Main
Wednesday, November 30, 2005
Using the Flex 2 Logging API with the Flex Trace Panel

Flex 2 comes with a great new Logging API. I've created an AS 3.0 class that allows you to route logging messages to the Flex Trace Panel.

To use the class, create the folder structure de/richinternet/logging inside your Flex 2 project and copy the TracePanelTarget class to this location. Inside your Flex 2 application you add a new instance of the TracePanelTarget as a target to the Log class, e.g.

import mx.logging.Log;
import mx.logging.LogEventLevel;
import de.richinternet.logging.TracePanelTarget;

private function initApp():Void
{
  var target:TracePanelTarget = new TracePanelTarget();
  target.level = LogEventLevel.DEBUG;
  Log.addTarget(target);
}

Later, you acquire an ILogger instance from the Log class and invoke a logging method on it. The parameter passed is the category you want a logger for (by convention the category maps to the fully qualified class name in which the logger is used):

Log.getLogger("foo").info("this is an info message!");
Log.getLogger("foo").warn("this is a warn message!");

For a full discussion of the Logging API check the Flex 2 documentation.

Please note that as of now the Flex Trace Panel is not fully compatible to Flex 2 - trying to trace complex objects will fail because some techniques used in the Dumper class no longer work in Flex 2. Also, I haven't adjusted the Flex Trace Panel log levels to the Flex 2 log levels yet. I will create an updated version of the Flex Trace Panel that fully supports Flex 2 in the future - so, just take it as a preview :)

Download available here.

Dirk.

Comments

There are no comments for this entry.



Sun Mon Tue Wed Thu Fri Sat
   1234
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

About this blog
www.aws-blog.de
www.richinternet.de
www.flexforum.de
www.die-flexperten.de

AIR (10)
Apollo (3)
BlazeDS (8)
Breeze (1)
Central (5)
Cocoon P2P (1)
ColdFusion (55)
Flash (61)
Flash Media Server (8)
Flex (170)
Flex Trace Panel (6)
FXUG (3)
J2Flex (4)
MAX (31)
Mobile (1)
mxmlc (1)
Other topics (47)
Plugins (9)
Video (7)


Recent Flex Technotes
Recent ColdFusion Technotes
Recent Flash Technotes

http://www.aws-blog.de
http://www.die-flexperten.de
http://www.flexforum.de
http://www.flex.org

Aggregated by fullasagoog.com
Aggregated by MXNA

Short Mode | Full Mode

Herrlich & Ramuschkat