This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Logging Configuration

Anchore services produce detailed logs that contain information about user interactions, internal processes, warnings and errors.

Log Level

The verbosity of the logs is controlled using the logging.log_level setting in config.yaml (for manual installations) or the corresponding ANCHORE_LOG_LEVEL environment variable (for docker compose or Helm installations) for each service.

The log levels are DEBUG, INFO, WARNING, ERROR, and CRITICAL, where the default is INFO. Most of the time, the default level is sufficient as the logs will container WARNING, ERROR and CRITICAL messages as well. But for deep troubleshooting, it is always recommended to increase the log level to DEBUG in order to ensure the availability of the maximum amount of information.

Changing Log Level via the API

The log level can be adjusted via the API without having to redeploy services:

echo '[{ "service_name": "all", "logging_level": "debug" }]' > log_level.json
curl -u {admin_user}:{admin_pass} -X POST -H 'Content-Type: application/json' -d @log_level.json http://localhost:8228/v2/system/logging

Changing Log Level via the UI

The log level can also be modified by a user with the system configuration permissions by navigating to System -> Configuration. Each service’s log level can be configured individually. Example for Analyzer Log Level:

alt text

Structured Logging (JSON)

Anchore services can be configured to log in JSON format. This is particularly helpful if users ship logs to an external log aggregator.

Helm

With our Helm chart’s values.yaml, users can change the structured logging boolean in the following section:

anchoreConfig:
  [...]
  logging:
    [...]
    structured_logging: true

Docker

With Docker Compose, users will need to mount the config.yaml file into the containers with the following section modified to enable structured logging:

logging:
  [...]
  structured_logging: true  # Enable structured logging output (JSON)

Mounting config.yaml file in Docker

To obtain the default config.yaml file that can then be modified and remounted, first get the file from the Enterprise image:

docker create --name temp docker.io/anchore/enterprise:{version}
docker cp temp:/config/config.yaml config.yaml
docker rm -f temp

Make the modifications in the config.yaml to enable structured logging, and mount it to each service. The following is an example for the API service, but for each service that structured logging needs to be enabled on, the config.yaml will need to be mounted similarly as a volume:

  # The primary API endpoint service
  api:
    [...]
    volumes:
      - ./license.yaml:/license.yaml:ro
      - ./config.yaml:/config/config.yaml:ro