Saturday, February 24, 2007

Logging and Debugging deployed Flex applications

I want to share my experience with troubleshooting Flex problem in deployed environment. I am working on a application that uses web service as back end. I do development and basic testing in Flex Builder so I can run debugger and see trace outputs.

But lately I decided to try run my app from web container (tomcat). The first problem I encountered was my login screen doesn't work. I pressed login and nothing happened. I have code that uses Application.application.url parameter to figure out host site and based on url decide where to locate web services. In local debug environment I use hardcoded url (and it works fine), in deployed one I have code that construct url dynamically (and obviously it wasn't working well).

What should I do?

Luckily Flex Builder provides an easy way to run remote application (loaded from web container) in debug mode. First you need to make sure that you used -debug=true flag when you compiled your application. Once you done it, you can create a new debug run configuration in Flex Builder and specify url of deployed application and related project:



Now you just need to set breakpoints, press debug and see why something doesn't work.

Remote debug mode is quite convenient if you have full control over environment. But eventually your application would be deployed in customer site and most likely you would not be able to use debugger to trace down your problem.

To address this problem you need to make sure you have enough log statements in your code that would help to pinpoint the problem so make sure you are aware about mx.logging.* package.

It's very similar to java logging api and should not take long to figure out. The main caveat is that to use default trace facility(mx.logging.targets.TraceTarget) you need to run debug version of flash player. TraceTarget allows you to output message to system.out (eclipse console) or flashlog.txt. To make sure that flashlog.txt is created, you need to check that you have mm.cfg in your user home directory (in my case I didn't have mm.cfg created by installer). If you don't have mm.cfg - create it in C:\Documents and Settings\{username}\( obviously this window specific, check manual for linux path) and populate with parameter you want to use for ex.:

ErrorReportingEnable=1
TraceOutputFileEnable=1
MaxWarnings=100

Now you would be able to see flashlog.txt in c:\Documents and Settings\{username}\Application Data\Macromedia\Flash Player\Logs\.


Most likely you would not be able to use debug flash player in customer environment. You can write your own extension of flex logging classes to make sure you can capture trace event somehow. But the easier way to start with already existing flex logging extension "trace panel" from Adobe Flex Exchange (or directly from author's site http://www.faratasystems.com/?page_id=45) . It provide log capturer win32 application and source code for AbstractTarget that communicates with the win32 app and shows log statement when using none-debug version of flash player.



Hope this was helpful. If know some other techniques that can be used in Flex to simplify problem troubleshooting let me know.

6 comments:

narahari said...

I am using flex application integrate with java. I have problem while debugging this.

i always wrrapping swf file in to jsp using AC_FL_RunContent() java script function.

how can i debug this swf file while it is running with jsp

Unknown said...

I am using flex application with .net. How can i debug the application?

Thanks in advance..

Display Name is Required said...

Thanks. I tried and it works!

optimusdad said...

Works great -- thanks!

Kitty said...

高収入!短期間で稼げる在宅バイト案内
高時給♪短期間に稼げるライブチャット案内
高時給♪すぐに稼げる副業案内
日払いOK!手軽に稼げる副業情報
高収入!好きな時に稼げるチャットレディー案内
週払いOK!簡単に稼げる副業情報
週払い可能◎高額仕事情報
昼間だけOK!家で稼げる在宅ワーク情報
稼げる携帯チャトレバイト情報
日払いOK!楽々稼げる在宅ワーク情報
高時給♪すぐに稼げるアルバイト案内
高時給♪自由な時間に稼げる家仕事案内
初心者OK!すぐに稼げる小遣い稼ぎ情報
高時給♪育児中でも稼げるチャトレ情報
昼間だけOK!簡単に稼げるバイト情報
楽々稼げる高額携帯メールレディ募集
空いた時間に稼げる高時給携帯チャトレ募集
高収入ライブチャットアルバイト情報
彼氏に内緒で稼げる高単価携帯ライブチャット
高収入!30代でも稼げる在宅ワーク情報
夜だけOK!手軽に稼げる在宅バイト情報
稼げるノンアダルト高額ライブチャット募集
高時給♪人妻でも稼げるライブチャット情報
週払い可能◎高単価チャットレディー
稼げる安心高額チャトレ募集
高収入!自宅で稼げるアルバイト案内
高収入!学生でも稼げる在宅バイト情報
素人でも稼げる高単価携帯メールレディ募集
秘密厳守!安全に稼げるメールレディ
稼げるライブチャット求人サイト

Kitty said...

淫乱若妻出会い系無料 ♪ 不倫奥さん出会いBBS ♪ セフレ募集人妻と出会える ♪ 淫乱若妻と出会える ♪ セフレ募集中40代出会い系 ♪ 愛人主婦出逢い系 ♪ セフレ希望30代と出会い ♪ セフレ新妻と出会える ♪ SEX好き30代出会いBBS ♪ 愛人募集30代出会い系無料 ♪ 浮気希望ギャル妻出会い ♪ 愛人募集主婦出会いBBS ♪ セフレ希望奥さん完全無料出会い ♪ エロ系若妻出会いBBS ♪ SEX好き新妻掲示板 ♪ 不倫エロ妻出合い ♪ エロ系人妻とやれる出会い系 ♪ 不倫若妻無料出会い系 ♪ エロ系40代出合い ♪ やれる主婦即アポ出会い ♪