Debugging and Logging
The Debugging and Logging section of the ColdFusion Administrator provides a set of tools that can help you understand what your applications are doing, where and when any performance bottle-necks are occurring, and whether any error messages are occurring without your knowledge. There is also a rich set of debugging options that make it easier to troubleshoot errors while coding. In short, this section is all about making it easier for you to identify and avoid problems, both during and after the development process.
The Debug Output Settings Page
The Debugging Settings page allows you to customize what exactly appears in the debugging output. This page also lets you monitor the ColdFusion server externally, via the command line or the System Monitor in Windows.
See Chapter 17, "Debugging and Troubleshooting," in Volume 1, to learn about ColdFusion debugging options.
Enable Robust Exception Information
ColdFusion error messages provide lots of useful information about your server and code to help you diagnose problems. Unfortunately, this information may also be useful to hackers trying to gain unauthorized access to your server. As such, this option should be enabled on development machines but not on production servers.
Enable AJAX Debug Log Window
To enable the pop-up Ajax debug window, check this box.
See Chapter 30 to learn about Ajax debugging.
Enable Request Debugging Output
Check this option to enable debugging output. Information about variables, queries, execution times, and more will begin appearing at the bottom of each page processed by ColdFusion. You can customize what information is included in the debugging output.
Custom Debugging Output
You can customize exactly what is included in the debugging output and how it's displayed with the options in this section.
Enable Performance Monitoring
If you're using ColdFusion with Windows, you can monitor the ColdFusion server with the standard Performance Monitor application that comes with Windows. This is the same application that you use to monitor internal Windows processes such as memory management and CPU use, or other Microsoft applications such as IIS or SQL Server.
Check this option to tell ColdFusion to make information available to the Performance Monitor. When enabled, the Performance Object called ColdFusion Server will be available for display and monitoring within the Performance Monitor.
To monitor performance with the Performance Monitor, follow these steps:
- Make sure the Enable Debugging option is checked, since it affects all options on this page of the Administrator.
- Make sure the Enable Performance Monitoring option is checked.
- Launch the Windows Performance Monitor (choose Start > Run > Perfmon) and select ColdFusion from the Performance Object list as the process to monitor. Select All Counters or add individual counters from the list.
The Performance Monitor will show a live graph of the various counters available, such as the number of database interactions per second, the average page execution time, and the number of currently executing page requests. If you wish, you can also add counters from other Performance Objects, such as the IIS object (to monitor the IIS Web server) or the Processor object (to monitor the CPU itself). Use the Help icon on the Performance Monitor toolbar for more information.
Enable CFSTAT
For non-Windows servers, you can use the CFSTAT command-line utility to take the place of the Performance Monitor. It doesn't show up as a nice graph, but it displays the same information.
To use CFSTAT, follow these steps:
- Make sure the Enable Debugging option is checked, since it affects all options on this page of the Administrator.
- Make sure the Enable CFSTAT option is checked.
- Do whatever is appropriate for the operating system you're using to execute the cfstat executable in the /bin folder (under the ColdFusion root). It's helpful to add a command-line switch of 1, so that the statistics will be updated once per second.
The Debugging IP Addresses Page
While ColdFusion's debugging output is certainly helpful to you as a developer, you probably don't want your users or beta testers to see it. You may also want to get rid of it from time to time while you work, to see what your pages will look like without it.
Rather than having to turn the debugging output on or off for the entire server at once, Cold-Fusion allows you to turn it on only for specific IP addresses. This allows you to selectively decide who receives the debugging information. To add an IP address, go to the Debugging IP Addresses page, type it in the IP Address field, and click Add. To remove an IP address, select it from the list and click Remove Selected.
The Debugger Settings Page
ColdFusion provides an Eclipse-based interactive debugger. To use the debugger, you must enable support on this page.
Allow Line Debugging
To turn on Eclipse debugging support, check this box.
Debugger Port
The ColdFusion debugger communicates with ColdFusion on a designated port. By default, this is port 5005, but any port value can be used if needed.
Maximum Simultaneous Debugging Sessions
ColdFusion allows multiple concurrent debugging sessions. Specify the maximum number of sessions needed here.
The Logging Settings Page
ColdFusion keeps detailed log files that can be extremely helpful for monitoring or debugging an application. This page controls how ColdFusion maintains the log files, and allows you to turn on some additional log files that aren't kept by default.
Log Directory
By default, ColdFusion stores all log files in the /logs folder (beneath the ColdFusion root). You can use this option to change the location of the log files.
Maximum File Size
When log files get very large, they can become unwieldy and hard to read. Use this option to set the maximum amount of information to keep in each log file. The default value is 5000 KB. When a log file exceeds this size, its contents are copied into a log archive file. Log archives are the same as the original log files, except that they are given an extension of .1, .2, and so on, instead of .log.
Maximum Number of Archives
A new archive file will be created each time the log file reaches 5000 KB (or whatever you specify). If you don't want an indefinite number of these archive files hanging around forever, you can tell ColdFusion to only maintain a certain number of archives for each log file. By default, a limit of ten archives is used. If, when the actual log file reaches 5000 KB, there are already ten archives present (perhaps application.1 through application.10), the oldest archive file is deleted.
Log Slow Pages
If you enable this option, a special entry in the server.log file will be made for any ColdFusion pages that take longer than the specified number of seconds to execute. You can use this information to identify bottlenecks in your application. (On some operating systems, you may also have an option to use OS logging features.)
Log All CORBA Calls
In you happen to be using CORBA objects in your application, enable this option to have Cold-Fusion log all CORBA interactions to the server.log file.
Enable Logging for Scheduled Tasks
If you are using ColdFusion's built-in task scheduler (see "The Scheduled Tasks Page" section in a moment and Chapter 36, "Event Scheduling"), you can enable this option to have all scheduler-related actions logged to a special log file called scheduler.log.
The Log Files Page
The Log Files page allows you to view and manage all of the log files on your server. Each .log file in the /log folder (or whatever log file location you have specified) is listed. For each log, icons are provided for viewing, downloading archiving, or deleting the log. When viewing a log, you can click the Launch Filter button to launch the Log Viewer filter window.
The Scheduled Tasks Page
ColdFusion has a built-in task scheduler, which allows you to create ColdFusion pages that run every few minutes or hours, or that execute at a certain time of day. Such pages are usually used to do things like sending mail, indexing collections, deleting temporary files that are no longer needed, and other administrative tasks.
For more information about scheduling tasks, see Chapter 36.
The System Probes Page
The System Probes page allows you to set up probes that check to see whether a particular page is executing normally. If not, ColdFusion can send you an email message so that you are among the very first to know when problems occur.
The System Probes page lists all currently defined probes. Icons are provided to edit or delete each probe. There is also a Disable/Enable icon for each probe, which you can use to temporarily turn a probe on or off. Finally, you can use the Run Probe icon to run a probe immediately, rather than waiting for it to run at its normally scheduled time or interval.
Define New Probe
To create a new probe, click the Define New Probe button. The Add/Edit System Probe page appears. This is discussed in further detail in Chapter 47.
System Probe Options
At the bottom of the System Probes page, you will find a number of options to control the way ColdFusion handles notification when a probe finds a problem:
- Notification Email Recipients. Provide a list of email addresses that ColdFusion should use when sending out a notification that a probe has found a problem. Everyone you specify here will receive a notification about every failed probe.
- E-mail. Specify a valid email address that ColdFusion's notification messages should use as their from field.
- Probe.cfm URL. Internally, the probe mechanism needs to be able to execute the Probe.cfm template in the CFIDE folder within your Web server root. If for some reason you need to move the template or place it on a different virtual server, edit the URL accordingly.
- Probe.cfm Username and Password. If you have used your Web server software to secure access to the Probe.cfm file with a username and password, enter that username and password here.
The Code Analyzer Page
While every effort is made to ensure backwards compatibility with prior versions of ColdFusion, it's always best to check your code before upgrading your server. The Code Analyzer page can help you identify most of the potential compatibility issues ahead of time, before you even try to run your application under ColdFusion.
To run the analyzer, specify the location of the application files you would like to test in the Directory to Analyze field, then click Run Analyzer. If you click the Advanced Options button, you will be able to tell ColdFusion which files to inspect (the default is all .cfm files), which incompatibilities to check for (the default is to check for all incompatibilities), which language elements to check, whether to display only serious problems (the Warn or the Info option), and more.
The License Scanner Page
Every non-Developer Edition of ColdFusion must be licensed. To help the system administrator, the License Scanner page can scan your local network and report the ColdFusion servers present and their license numbers.