Skip to content

File

The file log method can be used to send logs to a file. By default logs will be rotated and compressed to ensure the disk doesn't get filled up.

Configuration Keys

The following configuration keys apply to only the file target. The logging page lists general configuration which is shared with the syslog logger.

Key Type Default
structured Bool False
destination String /tmp/exacheck.log
size String 10MB
count Integer 5
compress Bool True
compression_format String gz

Structured

Structured logging can be enabled/disabled with the structured option. By default, logs sent to syslog servers are structured while file logs are not structured. An example of structured logs:

"date"="2024-01-21" "time"="14:05:05.949" "level"="INFO" "pid"="280406" "check_name"="TCP test to Google port 80" "file"="/code/exacheck/worker.py" "line"="201" "function"="success" "event"="info" "subsystem"="worker" "message"="Health check successful but service has not risen yet"

If disabled, the logs will look like this:

2024-01-21 14:21:27.731 | INFO     | 284611 | TCP test to Google port 80 | /code/exacheck/worker.py:201 | success | info | worker | Health check successful but service has not risen yet

Destination

The path to the log file. During startup the path is checked to ensure that the ExaCheck process can write to it.

Size

The maximum log file size before rotating the log file. Defaults to 10MB. Values can be specified in the format <size><unit>.

Count

The maximum number of rotated log files to keep.

Compress

The compress option allows for compression of rotated log files. If disabled, rotated logs will not be compressed.

Compression Format

The compression_format option specifies which format to use for log file compression. The list of valid options are:

  • gz
  • bz2
  • xz
  • lzma
  • tar
  • tar.gz
  • tar.bz2
  • tar.xz
  • zip

By default gz is used as it is most commonly available.

Examples

These are some examples of what can be configured for the file target.

A bare minimum configuration for logging to a file:

---

logging:

  # Basic file logger
  - method: file
    destination: /tmp/exacheck.log

# The list of health checks
checks:
    - ...

Logging to a file with filtering applied:

---

logging:

  # File logging with filtering applied for events and checks
  # Only announce and withdraw events will be logged
  - method: file
    destination: /tmp/exacheck-announcements.log
    size: 1MB
    count: 10
    events:
      - announce
      - withdraw
    checks:
      - Example Check 1
      - Example Check 2

# The list of health checks
checks:
    - ...