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:

[2025-01-14 19:12:49] [info] Submitting task signed by operators: 1
[2025-01-21 19:30:49] [warn] Failed to connect to peer 12D3KooWEsKHAZtWxBzqtHazZZN9vgnVo8bewpS6Vwfckub64jiV: TimeoutError: The operation was aborted due to timeout
[2025-01-14 19:13:17] [error] Server not running

2. File:

Logs are written to rotating files in JSON format, making them ideal for historical log analysis and archiving.

Example log entry:

circle-info

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.

circle-info

Configuration: Add these elasticsearch properties to your .env file:


Enable Debug logs

To enable detailed debug logs, add the following to your .env file:

This will activate verbose logging for all internal Stack components and services.


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.

circle-info

For distributed setups, use the Elastic stack (ELK) on Dockerarrow-up-right 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