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:

{
  "timestamp":"2025-01-14 19:00:25",
  "version":"1.7.0",
  "level":"info",
  "context":"P2P",
  "message":"Connected to peer: 12D3KooWCVRxMBPYMSk1QNyasXgrTyMbHWGHftAWQRGrWzkGj2Ly"
}

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.


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.

By leveraging logging capabilities, you can clearly understand the application's operations and quickly address any issues.

Last updated