2008. 9. 2. 16:17

[BlazeDS] 어플리케이션 디버깅 / Debugging your application

Reference : http://livedocs.adobe.com/blazeds/1/blazeds_devguide/build_apps_6.html#175144

어플리케이션에서 에러가 발생하면, 아래와 같은 동작을하는 디버깅 도구를 사용할 수 있습니다:

  • 코드에 브레이크포인트 지정 및 관리
  • 어플리케이션 일시 정지, 다시 시작, 어플리케이션 종료 등의 실행 제어
  • Step into and over the code statements
  • 주시할 중요 변수 선택
  • Evaluate watch expressions while the application is running

Debugging Flex applications can be as simple as enabling trace() statements or as complex as stepping into a source files and running the code, one line at a time. The Flex Builder debugger and the command line debugger, fdb, let you step through and debug ActionScript files used by your Flex applications. For information on how to use the Flex Builder debugger, see Using Adobe Flex Builder 3. For more information on the command line debugger, fdb, see Building and Deploying Adobe Flex 3 Applications.

Using Flash Debug Player
Flash Debug Player 사용  

fdb 커맨드 라인 디버거나 Flex Builder 디버거를 사용하려면 Flex Debug Player 를 설치하고 설정하십시오. Flash Debug Player 가 실행되는지, 표준 Flash Player 를 실행되는지 알고 싶다면, Flash Player 에서 Flex 어플리케이션을 열고 우클릭 하십시오. Show Redraw Regions 옵션이 보이면, Flash Debug Player 를 실행하고 있는 것입니다. Flash Debug Player 설치에 대한 정보는 BlazeDS 설치 가이드에서 볼 수 있습니다.

Flash Debug Player comes in ActiveX, Plug-in, and stand-alone versions for Microsoft Internet Explorer, Netscape-based browsers, and desktop applications. You can find Flash Debug Player installers in the following locations:

  • Flex Builder: install_dir/Player/os_version
  • Flex SDK: install_dir/runtimes/player/os_version/

Like the standard version of Adobe Flash Player 9, Flash Debug Player runs SWF files in a browser or on the desktop in a stand-alone player. Unlike Flash Player, the Flash Debug Player enables you to do the following:

  • Output statements and application errors to the local log file of Flash Debug Player by using the trace() method.
  • Write data services log messages to the local log file of Flash Debug Player.
  • View run-time errors (RTEs).
  • Use the fdb command line debugger.
  • Use the Flex Builder debugging tool.
  • Use the Flex Builder profiling tool.
Note: ADL logs trace() output from AIR applications.

Using logging to debug your application
어플리케이션 디버깅을 위한 로그 남기기

One tool that can help in debugging is the logging mechanism. You can perform server-side and client-side logging of requests and responses.

Client-side logging
클라이언트 로그 남기기

For client-side logging, you directly write messages to the log file, or configure the application to write messages generated by Flex to the log file. Flash Debug Player has two primary methods of writing messages to a log file:

  • The global trace() method. The global trace() method prints a String to the log file. Messages can contain checkpoint information to signal that your application reached a specific line of code, or the value of a variable.
  • Logging API. The logging API, implemented by the TraceTarget class, provides a layer of functionality on top of the trace() method. For example, you can use the logging API to log debug, error, and warning messages generated by Flex while applications execute.

Flash Debug Player sends logging information to the flashlog.txt file. The operating system determines the location of this file, as the following table shows:

Operating system

Location of log file

Windows 95/98/ME/2000/XP

C:\Documents and Settings\username\Application Data\Macromedia\Flash Player\Logs

Windows Vista

C:\Users\username\AppData\Roaming\Macromedia\Flash Player\Logs

Mac OS X

/Users/username/Library/Preferences/Macromedia/Flash Player/Logs/

Linux

/home/username/.macromedia/Flash_Player/Logs/

Use settings in the mm.cfg text file to configure Flash Debug Player for logging. If this file does not exist, you can create it when you first configure Flash Debug Player. The location of this file depends on your operating system. The following table shows where to create the mm.cfg file for several operating systems:

Operating system

Location of mm.cfg file

Mac OS X

/Library/Application Support/Macromedia

Windows 95/98/ME

%HOMEDRIVE%\%HOMEPATH%

Windows 2000/XP

C:\Documents and Settings\username

Windows Vista

C:\Users\username

Linux

/home/username

The mm.cfg file contains many settings that you can use to control logging. The following sample mm.cfg file enables error reporting and trace logging:

ErrorReportingEnable=1 TraceOutputFileEnable=1

After you enable reporting and logging, call the trace() method to write a String to the flashlog.txt file, as the following example shows:

trace("Got to checkpoint 1.");

Insert the following MXML line to enable the logging of all Flex-generated debug messages to flashlog.txt:

<mx:TraceTarget loglevel="2"/>

For information about client-side logging, see Building and Deploying Adobe Flex 3 Applications.

Server-side logging
서버 로그 남기기

You configure server-side logging in the logging section of the services configuration file, services-config.xml. By default, output is sent to System.out.

You set the logging level to one of the following available levels:

  • All
  • Debug
  • Info
  • Warn
  • Error
  • None

You typically set the server-side logging level to Debug to log all debug messages, and also all info, warning, and error messages. The following example shows a logging configuration that uses the Debug logging level:

<logging> <!-- You may also use flex.messaging.log.ServletLogTarget. --> <target class="flex.messaging.log.ConsoleTarget" level="Debug"> <properties> <prefix>[Flex]</prefix> <includeDate>false</includeDate> <includeTime>false</includeTime> <includeLevel>false</includeLevel> <includeCategory>false</includeCategory> </properties> <filters> <pattern>Endpoint</pattern> <!--<pattern>Service.*</pattern>--> <!--<pattern>Message.*</pattern>--> </filters> </target> </logging>

For more information, see Logging.

Measuring application performance
어플리케이션 성능 측정

As part of preparing your application for final deployment, you can test its performance to look for ways to optimize it. One place to examine performance is in the message processing part of the application. To help you gather this performance information, enable the gathering of message timing and sizing data.

The mechanism for measuring the performance of message processing is disabled by default. When enabled, information regarding message size, server processing time, and network travel time is captured. This information is available to the client that pushed a message to the server, to a client that received a pushed message from the server, or to a client that received an acknowledge message from the server in response a pushed message. A subset of this information is also available for access on the server.

You can use this mechanism across all channel types, including polling and streaming channels, that communicate with the server. However, this mechanism does not work when you make a direct connection to an external server by setting the useProxy property to false for the HTTPService and WebService tags because it bypasses the BlazeDS Proxy Server.

You use two parameters in a channel definition to enable message processing metrics:

  • <record-message-times>
  • <record-message-sizes>

Set these parameters to true or false; the default value is false. You can set the parameters to different values to capture only one type of metric. For example, the following channel definition specifies to capture message timing information, but not message sizing information:

<channel-definition id="my-streaming-amf"
class="mx.messaging.channels.StreamingAMFChannel"> <endpoint
url="http://{server.name}:{server.port}/{context.root}/messagebroker/streamingamf" class="flex.messaging.endpoints.StreamingAMFEndpoint"/> <properties> <record-message-times>true</record-message-times> <record-message-sizes>false</record-message-sizes> </properties> </channel-definition>

For more information, see Measuring message processing performance.