Table of contents
- Debug/Logging Client-Side – Part 1
- Debug/Logging Client-Side – Part 2
In my previous post I started to talk about how you can see the same trace messages you were used from developing but this time in the “Release”.
This is done with the help of the Log class (mx.logging.Log).
Let’s take a look at some pieces of code (full code can be provided per request).
private var myTarget:ILoggingTarget; myTarget = new TraceTarget(); Log.addTarget(myTarget); var myLogger:ILogger = Log.getLogger(category); myLogger.log(0,message);
The first 2 lines create a variable of type TraceTarget. Then it is added to the loggers list by calling
Log.addTarget(myTarget)
After that all we have to do is log the message:
myLogger.log(0,message);
How can we use this method to send the log output to a remote machine? Simple we have to create our own logger:
package com.qbic.logging { import flash.events.Event; import flash.net.XMLSocket; import mx.logging.LogEvent; import mx.logging.targets.LineFormattedTarget; internal final class remoteTarget extends LineFormattedTarget { public static var server_ip : String = "localhost"; public static var server_port : int = 6783; private var mySocket : XMLSocket; public function remoteTarget() { // Connect to the socket } public override function logEvent(myLogEvent:LogEvent) : void { mySocket.send(myLogEvent.message); } } }
Off course this is just a beginning of the code.
Tags: ActionScript, flex, RIA, XMLSocket
This post was written by Virgil Cristea
Views: 5612











Hi, can you please send me the code for this TraceTarget project. I couldn’t figure how to get it running, so any examples would be of great help.
Thanks
It would be great if you send me the code for this?
I am looking for the same for a long time.