Logging
Overview
Logging is essential to any application, providing critical insights into its behavior, aiding debugging, and ensuring seamless monitoring in production environments. Othentic CLI features a robust logging system, offering flexibility to log multiple destinations.
Log Levels
Logs are categorized by severity levels to help identify and filter specific types of messages:
info: General information about the application’s operation.
debug: Detailed information for debugging purposes. (included only in logs written to a file or sent to Elastic)
warn: Indications of potential issues.
error: Critical errors affecting the application.
Logging Destinations
Othentic CLI supports the following destinations:
1. Console (default):
Logs are printed directly to the standard output (stdout).
Example:
2. File:
Logs are written to rotating files in JSON format, making them ideal for historical log analysis and archiving.
Example log entry:
Configuration:
Add the following property to your .env
file to specify the log directory:
3. Elasticsearch:
Logs are sent to an Elasticsearch instance for storage and advanced analytics.
This is particularly useful in distributed environments where monitoring and querying logs is essential.
Configuration:
Add these elasticsearch properties to your .env
file:
Recommendations for Use
Development: Use the console destination for real-time feedback.
Production:
Configure file-based logging for historical data and compliance requirements.
Use Elasticsearch for advanced monitoring and visualization with tools like Kibana.
For distributed setups, use the Elastic stack (ELK) on Docker to configure and run Elastic stack on docker.
By leveraging logging capabilities, you can clearly understand the application's operations and quickly address any issues.
Last updated