The AEA framework supports flexible logging capabilities with the standard Python logging library.

In this tutorial, we configure logging for an AEA.

First of all, create your AEA.

aea create my_aea
cd my_aea

The aea-config.yaml file should look like this.

aea_version: '>=0.3.0, <0.4.0'
agent_name: my_aea
author: ''
connections:
- fetchai/stub:0.1.0
default_connection: fetchai/stub:0.1.0
default_ledger: fetchai
description: ''
fingerprint: ''
ledger_apis: {}
license: ''
logging_config:
  disable_existing_loggers: false
  version: 1
private_key_paths: {}
protocols:
- fetchai/default:0.1.0
registry_path: ../packages
skills:
- fetchai/error:0.1.0
version: 0.1.0

By updating the logging_config section, you can configure the loggers of your application.

The format of this section is specified in the logging.config module.

At this section you'll find the definition of the configuration dictionary schema.

Below is an example of the logging_config value.

logging_config:
  version: 1
  disable_existing_loggers: False
  formatters:
    standard:
      format: '%(asctime)s [%(levelname)s] %(name)s: %(message)s'
  handlers:
    logfile:
      class: logging.FileHandler
      formatter: standard
      level: DEBUG
      filename: logconfig.log
    console:
      class: logging.StreamHandler
      formatter: standard
      level: DEBUG
  loggers:
    aea:
      handlers:
      - logfile
      - console
      level: DEBUG
      propagate: False

This configuration will set up a logger with name aea. It prints both on console and on file with a format specified by the standard formatter.