Errors, Debugging, and Logging

Troubleshoot legacy ColdFusion without turning detailed exceptions and scope dumps into a production data leak.

Development Debugging

<cfdump var="#customer#" label="Customer Query">
<cfoutput>Template: #HTMLEditFormat(GetCurrentTemplatePath())#</cfoutput>

Debug output is useful in an isolated lab. In production it can expose queries, passwords, cookies, filesystem paths, server versions, source snippets, and personal data.

cftry and cfcatch

<cftry>
    <cfquery name="customer" datasource="support_portal">
        SELECT id, name
        FROM customers
        WHERE id = <cfqueryparam value="#variables.customerId#" cfsqltype="cf_sql_integer">
    </cfquery>

    <cfcatch type="database">
        <cflog file="application" type="error"
            text="Customer lookup failed: #cfcatch.message#">
        <cfthrow type="Application.CustomerLookupFailed"
            message="Unable to load customer.">
    </cfcatch>
</cftry>

Finally-Style Cleanup in MX

The cffinally tag arrived after the MX generation. In MX code, design resource use carefully and perform cleanup in a controlled outer flow. Many ColdFusion tags manage their own resources, but Java objects and custom integrations may require explicit cleanup.

Application-Level Error Handling

MX 7's Application.cfc provides onError. MX 6 applications may use cferror or carefully placed cftry/cfcatch.

<cferror
    type="exception"
    template="/errors/exception.cfm"
    mailto="">

The error template should not assume the database, session, mail server, or application configuration is healthy. Keep it small and resilient.

Logging

<cflog
    file="support-portal"
    type="information"
    application="yes"
    text="Ticket #variables.ticketId# created by user #session.userId#">

Log stable identifiers and useful operational context. Avoid logging passwords, full session tokens, payment data, or unnecessary personal information.

A Correlation ID

<cfset request.correlationId = CreateUUID()>

<cflog file="application" type="information"
    text="[#request.correlationId#] Request started: #cgi.script_name#">

Include the same correlation ID in related log lines and a generic error page. That lets an operator find the internal details without showing them to the user.

Useful Troubleshooting Sequence

  1. Confirm the exact URL, time, user, and action.
  2. Reproduce in an isolated environment with equivalent configuration.
  3. Check ColdFusion logs, web-server logs, database logs, and Windows Event Viewer or Unix service logs.
  4. Verify datasource connectivity and permissions.
  5. Inspect recent code, connector, Java, certificate, or database changes.
  6. Reduce the failure to the smallest template or query possible.
  7. Correct the root cause and remove temporary dumps or verbose debugging.

Common MX-Era Failure Clues

SymptomLikely Areas
Blank pageSuppressed exception, output disabled, malformed include, or web connector issue
Datasource not foundWrong DSN, missing driver, permissions, service account, or environment mismatch
Intermittent wrong dataUnscoped CFC method variables, shared-scope race, caching, or reused query variables
SSL/TLS failureOld Java protocol support or outdated certificate trust store
OutOfMemoryErrorJVM heap, large queries, file processing, runaway sessions, or application-scope data
404 for .cfm onlyIIS/Apache connector mapping or application-server connector failure