Debugging & Logging - Logging Settings

Configure logging levels and log file settings

Overview

Logging is essential for monitoring application health, troubleshooting issues, and maintaining security. The Logging Settings page in the ColdFusion Administrator allows you to configure how ColdFusion records events, errors, and diagnostic information. Proper logging configuration helps you quickly identify and resolve issues while minimizing performance impact and storage costs.

This guide covers log levels, log rotation, slow query logging, and best practices for production logging. Understanding these settings helps you balance comprehensive logging with system performance and disk space management.

Log Levels

Control how much detail ColdFusion logs by setting appropriate log levels for different environments.

Information

Use Case
General informational messages about normal operations
Includes
Server startup/shutdown, configuration changes, successful operations
Verbosity
Most verbose level

Best for development and troubleshooting, but generates significant log data.

Warning

Use Case
Potentially harmful situations that don't stop execution
Includes
Deprecated features, configuration issues with fallbacks, resource constraints
Recommended For
Production environments

Good balance between detail and noise for production monitoring.

Error

Use Case
Error events that might still allow application to continue
Includes
Handled exceptions, failed operations with fallbacks, database connection failures
Recommended For
Production environments

Captures critical issues without excessive logging.

Fatal Information

Use Case
Severe errors causing application shutdown
Includes
Unrecoverable errors, critical resource exhaustion, security violations
Verbosity
Least verbose level

Only logs the most critical failures requiring immediate attention.

Debug (CF 2021+)

Use Case
Detailed diagnostic information for troubleshooting
Includes
Variable values, execution flow, detailed stack traces
Warning
Never use in production

Development and troubleshooting only - significant performance impact.

Log Level Configuration

Global SettingApplies to all logs by default
Per-Log ConfigCan set different levels for specific logs
HierarchyHigher levels include lower levels
Information includes Warning, Error, and Fatal
Warning includes Error and Fatal
Error includes Fatal only
RecommendationProduction: Error or Warning level
Development: Information or Debug level
Troubleshooting: Temporarily increase to Information
Performance Impact: Higher log levels (more verbose) can impact performance and storage. Information level generates significantly more log data than Error or Warning.

Log Directory Configuration

Log Directory Path

Default Location{cfusion}/logs/
Windows ExampleC:\ColdFusion2023\cfusion\logs\
Linux Example/opt/coldfusion/cfusion/logs/
Custom PathCan specify alternate directory
PermissionsColdFusion service account must have write access
Custom Log Directory Benefits:
  • Separate logs from application files
  • Easier backup and archival
  • Can use dedicated storage with better I/O
  • Simplifies log aggregation
  • Use separate partition/drive for high-traffic sites
  • Ensure sufficient disk space and configure monitoring

Log File Rotation Settings

Control how ColdFusion rotates log files to manage disk space while retaining historical data.

Maximum Log File Size

PurposeLimit individual log file size before rotation
Default2000 KB (2 MB)
Range100 KB to unlimited
RecommendationSmall sites: 5-10 MB
Medium sites: 10-25 MB
Large sites: 25-50 MB
ConsiderationSmaller files rotate more frequently, larger files easier to manage

Maximum Number of Archives

PurposeHow many rotated log files to keep before deletion
Default10 archives
Range1 to 999
Recommendation10-30 depending on retention requirements
CalculationTotal log storage = Max Size × (Archives + 1)
Example10 MB max size × 10 archives = ~110 MB per log type
Compliance Consideration: May need higher values for regulatory requirements (GDPR, HIPAA, etc.)

Log Rotation Behavior

When It HappensWhen current log file exceeds maximum size
File NamingOriginal file archived with timestamp
Example: application.log becomes application.log.2025-01-28
Oldest ArchiveDeleted when archive count exceeds maximum
New LogFresh log file created with original name
DowntimeRotation happens seamlessly during logging - no interruption
Best Practices:
  • Set file size limits to prevent individual files from becoming too large
  • Configure enough archives to cover troubleshooting period (typically 7-30 days)
  • Monitor total log directory size
  • Consider external archival for long-term retention
  • Use log aggregation tools for better management
  • Test restore procedures for archived logs

Slow Query Logging

Identify and optimize database performance bottlenecks by logging queries that exceed specified execution times.

Enable Slow Query Logging

PurposeLog database queries exceeding threshold time
DefaultDisabled
RecommendationEnable for performance monitoring
Log Fileslowquery.log
BenefitIdentify performance bottlenecks in database queries

Slow Query Threshold (seconds)

PurposeMinimum execution time to log a query
Default3 seconds
RangeAny positive number (can be decimal, e.g., 0.5)
RecommendationProduction: 1-3 seconds (identify truly slow queries)
Development: 0.1-0.5 seconds (catch all inefficiencies)
High-performance apps: 0.05-0.1 seconds
ConsiderationLower thresholds generate more log entries

What Gets Logged

Query TextFull SQL statement that executed slowly
Execution TimeHow long the query took
Template PathWhich CFM/CFC file executed the query
Line NumberExact location in the template
DatasourceWhich database connection was used
TimestampWhen the slow query occurred
Best Practices:
  • Always enable slow query logging in production
  • Set threshold based on application performance requirements
  • Review slow query logs weekly or after deployments
  • Use cfqueryparam for better query performance and security
  • Consider caching frequently executed slow queries
  • Work with DBAs to optimize flagged queries
  • Monitor trends to catch performance degradation early

Additional Logging Options

CORBA Call Logging

Default
Disabled
Log File
corba.log
Recommendation
Only enable when troubleshooting CORBA

Legacy feature - CORBA rarely used in modern ColdFusion applications.

Schedule Task Logging

Default
Enabled (recommended)
Log File
scheduler.log
Logs
Task start/completion times, execution status, error details

Always enable for scheduled task monitoring and troubleshooting.

Mail Logging

Default
Error level
Log Files
mail.log, mailsent.log
Logs
Recipients, subjects, SMTP connections, send status

Monitor mail.log regularly for email delivery issues.

Exception Logging

Default
Always enabled
Log File
exception.log
Logs
Exception type, message, stack trace, template path, request context

Critical - monitor exception.log closely in production environments.

Production Logging Best Practices

Log Level Configuration

  • Use Error or Warning level for production (minimize noise)
  • Temporarily increase to Information for troubleshooting
  • Never use Debug level in production (performance impact)
  • Configure per-log levels for fine-grained control
  • Document when and why log levels are changed

Storage and Retention

  • Size log files appropriately for rotation frequency
  • Keep enough archives to cover typical incident investigation period
  • Use separate disk/partition for logs on high-traffic sites
  • Implement external archival for long-term retention
  • Monitor disk space and set up alerts
  • Compress old logs to save space

Security Considerations

  • Protect log files with appropriate file system permissions
  • Never log sensitive data (passwords, credit cards, PII)
  • Sanitize user input before logging
  • Regularly review logs for security incidents
  • Implement log integrity monitoring (detect tampering)
  • Comply with data retention regulations (GDPR, HIPAA, etc.)

Performance Optimization

  • Use appropriate log levels to reduce I/O overhead
  • Consider asynchronous logging for high-traffic applications
  • Use fast storage (SSD) for log directories
  • Avoid logging in tight loops or high-frequency operations
  • Implement log sampling for very high-volume events

Monitoring and Alerting

  • Monitor exception.log for application errors
  • Alert on Fatal level messages immediately
  • Track error rates and trends over time
  • Review slowquery.log regularly for performance issues
  • Set up alerts for disk space consumption
  • Monitor log file growth rates

Structured Logging Recommendations

What Is Structured Logging?

  • Definition: Logging in machine-parseable format (JSON, XML, etc.)
  • Benefits:
  • Easier automated analysis
  • Better integration with log aggregation tools
  • More efficient searching and filtering
  • Enables advanced analytics and dashboards
  • Comparison: Traditional text logs vs structured JSON logs

Implementing Structured Logging

  • Custom Logging: Create JSON-formatted log entries
  • Include Standard Fields:
  • timestamp - When event occurred
  • level - Log severity (ERROR, WARN, INFO)
  • message - Human-readable description
  • context - Request ID, user ID, session ID
  • application - Application name/version
  • server - Server hostname/instance
  • Use cflog: Write to custom log files
  • Consider Log4j: Advanced logging framework (Java-based)

Example Structured Log Entry

  • JSON Format:
  • {"timestamp":"2025-01-28T10:30:45Z","level":"ERROR","message":"Database connection failed","datasource":"myDB","error":"Connection timeout","requestId":"abc123","userId":"user@example.com"}
  • Benefits: Easy to parse, search, and analyze programmatically

Log Aggregation and Analysis

Why Use Log Aggregation?

  • Centralization: Collect logs from multiple servers in one place
  • Search: Quickly find relevant log entries across all systems
  • Correlation: Connect related events across different logs
  • Visualization: Dashboards and charts for trends and patterns
  • Alerting: Automated notifications for critical events
  • Retention: Long-term storage with compression

Popular Log Aggregation Tools

  • ELK Stack (Elasticsearch, Logstash, Kibana):
  • Open source, powerful search and visualization
  • Industry standard for log management
  • Scales to billions of log entries
  • Splunk:
  • Commercial enterprise log management
  • Advanced analytics and machine learning
  • Excellent visualization and reporting
  • Graylog:
  • Open source alternative to Splunk
  • Built on Elasticsearch
  • Good balance of features and simplicity
  • Cloud Solutions:
  • AWS CloudWatch Logs
  • Azure Monitor Logs
  • Google Cloud Logging
  • Datadog, New Relic, Sumo Logic

Integrating ColdFusion with Log Aggregation

  • File-Based: Use Filebeat or Logstash to ship log files
  • Syslog: Configure CF to send logs to syslog server
  • HTTP/API: Custom logging to API endpoints
  • Agent-Based: Install monitoring agent on CF server
  • Recommendation: Use Filebeat with ELK for cost-effective solution

Common Issues and Solutions

Log Files Growing Too Large

  • Symptom: Log directory consuming excessive disk space
  • Causes:
  • Log level too verbose (Information or Debug)
  • Application errors generating excessive logs
  • Max file size or archive count too high
  • External archival not configured
  • Solutions:
  • Reduce log level to Warning or Error
  • Fix application issues causing errors
  • Reduce max file size and archive count
  • Implement external log archival and cleanup
  • Compress or delete old archived logs

Missing Log Entries

  • Symptom: Expected log entries not appearing
  • Causes:
  • Log level set too high (filtering out entries)
  • Application using cflog to different file
  • Buffering delay in log writing
  • Disk full preventing log writes
  • Solutions:
  • Lower log level temporarily
  • Check custom log files
  • Verify disk space availability
  • Check file permissions

Slow Query Logging Not Working

  • Symptom: No entries in slowquery.log despite slow queries
  • Causes:
  • Slow query logging disabled
  • Threshold set too high
  • Queries actually executing quickly
  • Solutions:
  • Enable slow query logging in administrator
  • Lower threshold to catch queries
  • Verify query execution times with debugging

Log Rotation Not Occurring

  • Symptom: Log files exceeding configured size limits
  • Causes:
  • Max file size set to very large value
  • Rotation disabled
  • File permissions preventing rotation
  • Solutions:
  • Verify rotation settings in administrator
  • Check file system permissions
  • Restart ColdFusion to apply new settings

Troubleshooting with Logs

Essential Logs for Troubleshooting

  • exception.log: Application errors and unhandled exceptions
  • application.log: General application events and messages
  • server.log: Server startup, shutdown, and configuration
  • slowquery.log: Database performance issues
  • mail.log: Email sending problems
  • scheduler.log: Scheduled task execution

Common Error Patterns

  • OutOfMemoryError: Heap exhaustion (check JVM settings)
  • Database connection errors: Datasource configuration or network issues
  • Template not found: Mapping or path resolution problems
  • Method not found: Component or function calling errors
  • Null pointer: Variable scope or initialization issues

Log Analysis Techniques

  • Search for specific error messages or stack traces
  • Correlate timestamps across different log files
  • Look for patterns in error frequency and timing
  • Compare logs before and after deployments
  • Use grep/findstr for command-line log searching
  • Leverage log aggregation tools for advanced queries

Related Resources