Skip to content

Logging

Edge Xpert provides the feature of logging, which can fetch the log information of each service.

Using Logs

By looking into the service's log, you can do the following:

  • monitor and get access to the information of each service
  • understand how the services interact with others
  • services' performance improvement
  • trouble shooting

The Edge Xpert microservice logs provide the following information:

  • Timestamp
  • Originating service
  • Log level
  • Logged message

Viewing the Logs

You can collect Edge Xpert logs using the Edge Xpert CLI by either:

View Logs In Terminal

To view the log associated with other services, enter the following command by replacing with the name of targeted service:

docker logs <service>

For example, to view the logs of Core Data, enter the following command:

docker logs core-data

The output is similar to the following:

Edge Xpert Licensing: Validating License File EdgeXpert_Alison_Evaluation.lic
Edge Xpert Licensing: Signature valid
Edge Xpert Licensing: License valid
Edge Xpert Licensing: Service Licensed
level=INFO ts=2020-11-20T11:25:46.888243274Z app=edgex-core-data source=config.go:219 msg="Loaded configuration from res/configuration.toml"
level=INFO ts=2020-11-20T11:25:46.888792556Z app=edgex-core-data source=environment.go:331 msg="Environment override of 'Registry.Host' by environment variable: Registry_Host=edgex-core-consul"
level=INFO ts=2020-11-20T11:25:46.888821551Z app=edgex-core-data source=environment.go:331 msg="Environment override of 'Clients.Logging.Host' by environment variable: Clients_Logging_Host=edgex-support-logging"
level=INFO ts=2020-11-20T11:25:46.888849069Z app=edgex-core-data source=environment.go:331 msg="Environment override of 'Databases.Primary.Host' by environment variable: Databases_Primary_Host=edgex-redis"
.....

You can use the following options with the docker logs command in the format docker logs [options] <container>:

Option Description
--details Display extra details provided to logs
--follow
-f
Follows the log output
--since Displays the logs since the specified timestamp or relative time.

For example, specifying --since 2013-01-02T13:23:37 displays the logs from the timestamp 13:23:37 on 02/01/2013.

For example, specifying --since 42m displays the logs from the last 42 minutes
--tail Defines the number of lines to show from the end of the logs.

Default is all
--timestamps
-t
Displays the timestamps
--until Used only in the Docker Engine API version 1.35 or later

Displays the logs until the specified timestamp or relative time

For example, specifying --until 2013-01-02T13:23:37 displays the logs until 13:23:37 on 02/01/2013

For example, specifying --until 42m displays the logs for the next 42 minutes

For further information on the docker logs, refer to the Docker documentation

Send Logs to an Output Directory

To send the log associated with a service to an output directory, enter the following command replacing <services> with the names of the containers for which you want to save logs, and <output_directory> with the name of the directory in which to save the logs:

edgexpert logs <services> -o <output_directory>

For example, the following command saves all logs from the Modbus Device Service to the Logs directory:

edgexpert logs device-modbus -o Logs

Log Levels

You can change the log level to increase or decrease the amount of information that is logged.

The following table describes the log levels used in Edge Xpert:

Log Level Description
TRACE Logs low-level information from the service

For example, data received and sent using GET and PUT requests
DEBUG Logs detailed information about the service

For example, Device Services log all GET and PUT requests
INFO Logs high-level information

For example, standard start-up information and whenever a device is registered or removed

This is the default log level
WARN Logs unexpected events in the application, a problem, or a situation that might disturb one of the processes but not necessarily cause the application to fail

For example, unable to Get service endpoint for core-metadata
ERROR Logs errors

For example, failed GET or PUT requests or device provisioning

Configure the Log Level

You can change the service's log level by editing its configuration on Xpert Manager UI service control page. Alternatively, you can change its log level by using docker compose override mechanism. The log level is set in the environment section for the relevant service in the docker-compose.yaml file.

Note

Please refer to the Docker Compose override capability for full details.

environment:
  WRITABLE_LOGLEVEL: DEBUG
You can also configure the maximum size of the log files and the maximum number of log files in the environment section for the relevant service in the docker-compose.yaml file, as shown below:

logging:
  driver: "json-file"
  options:
    max-size: "10mb"
    max-file: "20"