Consul: Logs are being created to syslog with a timestamp even when the file was specified in log_file.

Created on 31 Dec 2019  路  2Comments  路  Source: hashicorp/consul

Overview of the Issue

I want to write my logs to /var/log/consul/consul_server.log and for that I've added this to my Consul configuration:

"log_level": "INFO",
"log_file": "/var/log/consul_server.log",
"enable_syslog": true, 

After reloading Consul it's writing logs to the specified path however, it's not respecting the filename (consul_server.log) and it keeps adding a UNIX timestamp to my logs so my file looks like this: consul_server-1577827892114875204.log.

According to the documentation the log_file option is used _to redirect all the Consul agent log messages to a file. [...] In case the path doesn't have the filename, the filename defaults to consul-{timestamp}.log_ but I'm giving the path with the filename so a timestamp should not be added.

Reproduction Steps

  1. Create a cluster Vault cluster and a Consul cluster of 3 nodes each one.
  2. Add the options shown above to the Consul configuration.
  3. Reload Consul.
  4. Try to access the logs with the specified filename.

Consul info for both Client and Server


Server info

agent:
    check_monitors = 0
    check_ttls = 0
    checks = 0
    services = 0
build:
    prerelease =
    revision = 1200f25e
    version = 1.6.2
consul:
    acl = disabled
    bootstrap = false
    known_datacenters = 1
    leader = false
    leader_addr = 172.31.2.141:8300
    server = true
raft:
    applied_index = 18558
    commit_index = 18558
    fsm_pending = 0
    last_contact = 38.393087ms
    last_log_index = 18558
    last_log_term = 4
    last_snapshot_index = 16384
    last_snapshot_term = 4
    latest_configuration = [{Suffrage:Voter ID:c2d2e7bd-8c0e-1a2e-0db7-f38f524ea5a6 Address:172.31.31.106:8300} {Suffrage:Voter ID:f35b6204-33bc-e096-4363-e3736cfcc538 Address:172.31.2.141:8300} {Suffrage:Voter ID:60965527-9388-55b7-a823-0691f4d72160 Address:172.31.54.30:8300}]
    latest_configuration_index = 1
    num_peers = 2
    protocol_version = 3
    protocol_version_max = 3
    protocol_version_min = 0
    snapshot_version_max = 1
    snapshot_version_min = 0
    state = Follower
    term = 4
runtime:
    arch = amd64
    cpu_count = 1
    goroutines = 88
    max_procs = 1
    os = linux
    version = go1.12.13
serf_lan:
    coordinate_resets = 0
    encrypted = false
    event_queue = 0
    event_time = 4
    failed = 0
    health_score = 0
    intent_queue = 0
    left = 0
    member_time = 15
    members = 6
    query_queue = 0
    query_time = 1
serf_wan:
    coordinate_resets = 0
    encrypted = false
    event_queue = 0
    event_time = 1
    failed = 0
    health_score = 0
    intent_queue = 0
    left = 0
    member_time = 15
    members = 3
    query_queue = 0
    query_time = 1

Operating system and Environment details

OS: Amazon Linux 2 (Fully updated)
Architecture: x86_64

All 2 comments

It seems is intended #4697

Can you check the rsyslog configuration file? maybe an entry was added for consul that is not following the format, also try to stop consul and delete all log files, then just touch the log file in /var/log/consul_server.log

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nicholasjackson picture nicholasjackson  路  3Comments

wargamez picture wargamez  路  4Comments

wing731 picture wing731  路  3Comments

hooksie1 picture hooksie1  路  3Comments

powerman picture powerman  路  3Comments