Flex提供了类似于JAVA中的日志功能(首先得安装flashplayer_10_ax_debug),具体操作如下所示:
1、提供一个配置文件mm.cfg,类似于log4j.properties文件,不过该文件的所在的目录跟log4j有所不同,mm.cfg文件所在的目录跟操作系统有关:
Macintosh OS X | /Library/Application Support/Macromedia |
Windows 95/98/ME | %HOMEDRIVE%/%HOMEPATH% |
Windows 2000/XP | C:/Documents and Settings/username |
Windows Vista/7 | C:/Users/username |
Linux | /home/username |
2、在mm.cfg文件中配置如下内容:ErrorReportingEnable=1
3、依然根据操作系统的不同,到相应的目录查看记录的日志
Windows 95/98/ME/2000/XP | C:/Documents and Settings/username/Application Data/Macromedia/Flash Player/Logs |
Windows Vista/7 | C:/Users/username/AppData/Roaming/Macromedia/Flash Player/Logs |
Macintosh OS X | /Users/username/Library/Preferences/Macromedia/Flash Player/Logs/ |
Linux | /home/username/.macromedia/Flash_Player/Logs/ |
最后,附上可以在mm.cfg文件中配置的内容:
ErrorReportingEnable | Enables the logging of error messages. Set the ErrorReportingEnable property to 1 to enable the debugger version of Flash Player to write error messages to the log file. To disable logging of error messages, set the ErrorReportingEnable property to 0. The default value is 0. |
MaxWarnings | Sets the number of warnings to log before stopping. The default value of the MaxWarnings property is 100. After 100 messages, the debugger version of Flash Player writes a message to the file stating that further error messages will be suppressed. Set the MaxWarnings property to override the default message limit. For example, you can set it to 500 to capture 500 error messages. Set the MaxWarnings property to 0 to remove the limit so that all error messages are recorded. |
TraceOutputFileEnable | Enables trace logging. Set TraceOutputFileEnable to 1 to enable the debugger version of Flash Player to write trace messages to the log file. Disable trace logging by setting the TraceOutputFileEnable property to 0. The default value is 0. |
TraceOutputFileName | Note: Beginning with the Flash Player 9 Update, Flash Player ignores the TraceOutputFileName property and stores the flashlog.txt file in a hard-coded location based on operating system. For more information, see Log file location. Sets the location of the log file. By default, the debugger version of Flash Player writes error messages to a file named flashlog.txt, located in the same directory in which the mm.cfg file is located. Set TraceOutputFileName to override the default name and location of the log file by specifying a new location and name in the following form: On Macintosh OS X, you should use colons to separate directories in the TraceOutputFileName path rather than slashes. TraceOutputFileName=<fully qualified path/filename> |