Logging best practices
Follow these guidelines when implementing logging in Itential Platform adapters, applications, and integrations.
Before you begin
- Understand log formats and severity levels
- Know your Platform version (affects logging signature requirements)
- Review your organization’s data security policies
Itential’s logging security policy
Itential Platform automatically excludes Authentication, Authorization, and Accounting (AAA) sensitive data from logs, including Platform passwords, API keys, tokens, and credentials.
However, Itential does not modify third-party system payloads.
Third-party payload data
Platform does not filter data from external systems:
- API responses from external systems (ServiceNow, Ansible, Splunk)
- Device configurations from network equipment (Cisco, Juniper, Arista)
- Authentication tokens from external auth providers (Okta, Active Directory)
- Data returned from monitoring tools, ticketing systems, and cloud providers
Your responsibility
You must filter sensitive data from third-party payloads before logging.
Implement appropriate filtering in your workflows and custom code according to your organization’s security policies.
Always create context objects containing only known-safe fields. Never log entire objects that may contain sensitive data.
Use structured logging
Requirements: Platform 2023.2 or 6.2+
Use the structured logging signature with a single object containing message, context, and error fields.
Do this:
Not this:
Structured logging enables automated parsing and prevents accidental exposure of sensitive data.
Migrate to structured logging
Requirements: Platform 2023.2 or 6.2+
Update existing multi-argument log calls to structured logging format.
Before migration:
After migration:
Migration steps:
Choose the correct log level
Select appropriate severity level based on event type and required response.
Best practices for log levels
- Use
infofor events you’d want in production dashboards - Use
debugonly during active troubleshooting - Reserve
errorfor situations requiring human intervention - Always include
errorobjects witherrorandwarnlevels - Never use
traceorspamin production
Write clear messages
Write log messages that explain what happened and provide troubleshooting context.
Do this:
Not this:
Message guidelines
- State what operation was attempted
- Include relevant identifiers (user ID, resource ID)
- Explain the outcome (success, failure, retry)
- Provide context for troubleshooting
- Avoid generic messages like “Error occurred” or “Processing complete”
Filter sensitive data
Always create context objects containing only known-safe fields.
Create safe context objects
Extract only the fields you need and explicitly define them.
Do this:
Not this:
Filter third-party payloads
Extract only metadata from third-party responses. Never log full response bodies.
Do this:
Not this:
Sensitive data categories
Platform data (handled by Itential):
- Platform passwords, API keys, tokens, secrets
- Platform authorization headers, cookies, sessions
- Platform JWT tokens, OAuth credentials
Third-party data (your responsibility):
- API response payloads from external systems
- Device configurations from network equipment
- Credentials or tokens in third-party responses
- Customer data from external integrations
Personally Identifiable Information:
- Email addresses, phone numbers, full names
- Social security numbers, addresses
- IP addresses (context-dependent)
Business & customer data:
- Customer-specific business data
- Proprietary configurations
- Sensitive content from third-party systems
Log useful context
Include relevant context that helps diagnose issues without exposing sensitive data.
API calls
Log metadata about API requests and responses:
Include:
- HTTP method, endpoint (without sensitive query parameters)
- Status codes, response times
- Correlation IDs, operation names
- Record counts
Exclude:
- Request/response bodies
- Authorization headers
- API keys in URLs
- Full third-party payloads
Database operations
Log query metadata and execution details:
Include:
- Collection/table name
- Operation type
- Query parameters (if not sensitive)
- Success/failure status
- Execution time
Exclude:
- Full result sets
- Connection strings with credentials
- Entire documents with PII
Workflows
Log workflow execution details:
Include:
- Workflow name and ID
- Initiating user (username only)
- Count of affected resources
- Execution stage
Exclude:
- Complete workflow payloads
- Device configurations
- Credential data
- Full third-party responses
Authentication
Log authentication events for security auditing:
Include:
- User identifier
- Authentication method
- Success/failure status
- Source IP (if relevant)
Exclude:
- Passwords, credentials
- Full authentication payloads
- Session tokens
Third-party integrations
Log integration operation metadata:
Include:
- Metadata about the operation
- Device ID, data size, timing
- Success/failure
Exclude:
- Full configurations
- Credentials
- Proprietary settings
- Customer data
Handle errors
Always include error objects with error and warn level logs.
Error handling best practices
- Explain what the code was trying to do when it failed
- Include relevant identifiers (user ID, resource ID)
- Include the error object for stack traces
- Don’t log the same error multiple times as it propagates
- Use appropriate log level (error vs warn)
Use appropriate log frequency
Log summaries of batch operations rather than individual iterations.
Do this:
Not this:
Frequency best practices
- Log summaries of batch operations, not individual iterations
- Use
traceorspamfor high-frequency events during development - Remove or reduce verbosity in production code
- Consider performance impact of excessive logging
Common logging patterns
Successful operation
Recoverable warning
Unrecoverable error
Debug information
Third-party payload filtering
Do this - Log metadata only:
Not this - Logging full configuration:
Automated validation
Requirements: Platform 2023.2 or 6.2+
Platform automatically validates logging code during development.
Validation checks:
- All log calls pass a single object as argument
- Object contains a
messageproperty contextproperty (if present) is an objectlog.errorandlog.warncalls include anerrorproperty
Code violating these rules triggers ESLint warnings.
Valid:
Invalid:
Multi-argument logging (Platform 2023.1 and earlier)
For Platform versions before 2023.2, use multi-argument logging signature.
Pass only safe, specific values as arguments:
Never pass entire objects:
Legacy logging best practices
- Only pass specific, known-safe values as arguments
- Avoid passing request, response, user, or configuration objects
- Manually extract safe fields before logging
- Filter third-party payloads before logging any data
Performance considerations
Logging overhead
- Console logging has higher performance impact than file logging
- Structured JSON logging is more efficient than standard format
- Excessive logging in hot paths impacts performance
- Log level affects volume and performance
Production recommendations
- Use
infoorwarnlog level - Disable
debuglogging - Never use
traceorspam - Log summaries of batch operations
- Monitor log volume and performance impact