patroni
patroni copied to clipboard
Logging
Hi there, can someone help to clear unnecessary logs, such us
фев 06 14:42:07 user-VirtualBox patroni[14532]: 2018-02-06 14:42:07,473 INFO: Lock owner: postgresql0; I am postgresql0
фев 06 14:42:07 user-VirtualBox patroni[14532]: 2018-02-06 14:42:07,482 INFO: no action. i am the leader with the lock
I tried to change postgresql parameters, such us:
log_min_messages: 'NOTICE'
client_min_messages: 'NOTICE'
log_min_error_statement: 'NOTICE'
and init.py on source:
logging.basicConfig(format=logformat, level=logging.WARNING)
But nothing changes
Hi,
Those are not PostgreSQL, but Patroni logs, so changing PostgreSQL parameters won't affect them. Why do you think they are 'unnecessary'? Patroni reports every iteration of the event loop its role and who is the leader. Knowing that is important in order to understand, for instance, why did the failover happen.
You can mute the INFO messages from the event loop by setting the level in a ha.py
.
We may also provide some way of controlling log levels in the future. Feel free to contribute a PR if you are interested.
I've submitted #622 to make log level configurable using environment vars, but as these are at INFO level it'd still require hacking ha.py to mute the event loop messages.
Alexey, thanks for answer. Because system work stable, without reboot and changes, but they write to syslog every second. I really need only first message who i master and messanges when patroni change master, no more
@mrquokka feel free to submit a PR. I think it makes sense to have a group of N messages (so that Patroni says 'Leader with a lock (repeated N times)'.
@antineutron I think your PR needs to change how the loggers are spawned, so that there is a single place to set the logging level. Also, we might want to set this parameter in the configuration file rather than via the environment variables (and change it with a reload of Patroni without stopping its operations).
- to log repeating messages about leader & lock in batches. For example, in config set logging option 'log_batches: 100' and then buffer repeated messages in memory. Write it to disk like
[Repeated 100 times] : Lock owner: postgresql0; I am postgresql0; no action; i'm a leader with the lock
In one string Other messages, of course, write immediately.