tags:

views:

1490

answers:

4

Is there any way to capture the trace statements of your Flex app while not running in debug mode?

Or is there any other way to output logging information when not running a debugger?

Currently I'm trying to fix a bug that only presents itself in very specific deployment scenario, but I could see this being useful in some instances for customers to send logs to tech support when they are reporting bugs or other problems.

+2  A: 

I suppose you're talking about Adobe Flex, targeting the Flash Player?

If so, you can write your own logging wrapper class that propagates log messages sent to it to several targets (like the trace stack and internal memory so that you can access the log from within the app and e.g. send it to a server when the user agrees to send a bug report). Also see the Flex logging framework for something like this that already exists.

I've actually done something like this -- I have a class called Log with static methods like log(), debug(), error() etc. that I use in my apps, and this class forwards all messages sent to it into the trace stack via trace(), into a "log console" app running on the same host via LocalConnection and/or Socket (a socket connection is obviously a lot faster than LocalConnection) and also saves them locally into an array so that users can send bug reports along with the log output right from within the app.

This sort of a change of course means that you'd have to translate all trace() commands in your code into calls to the logging system, but that can be easily achieved with a regex search & replace.

hasseg
A: 

You can try XPanel from Farata Systems. This is a native Windows UI that can show log messages using the Flex 3 Logging API even for Flex applications running in a browser. Unfortunately they have redesigned their site and I can't find it anymore... Maybe Google will help you.

We did something different using JavaScript. The customer can open a 'special' page that shows logging and trace statements using DHTML. The Flex application calls a JavaScript function that tells the application, whether this page is opened or not. If it is not, logging is disabled. If it is opened, logging is enabled and all log statements are appended to this page.

Note that there is no way to write logging output to the filesystem all the time due to sandbox restrictions. However a customer can easily copy and paste the output of the logging window as explained above.

Yaba
+1  A: 

There's a project on Google Code called Thunder Bolt that allows you to write log messages that will appear in FireBug when running the application in Firefox (assuming of course that you have that extension installed.)

Logging with this tool is as simple as:

import org.osflash.thunderbolt.Logger;

var myNumber: int = 5;
var myString: String = "Lorem ipsum";
Logger.error ("Logging two objects: A number typed as int and a string", myNumber, myString);
Mike Deck
A: 

I've used alcon in the past.

http://blog.hexagonstar.com/alcon/

Joeri Sebrechts