Stellar logs are getting larger and larger. How do you get them to print log logs according to time rules
3 Answers
For Linux-based systems logrotate
is a standard option in such cases. Here you will find all details regarding installation and usage for your Linux distributive.
It allows to set up custom schedule for Stellar Core/Horizon log rotation. Example config:
/var/log/stellar/* {
daily
rotate 2
size 2M
compress
delaycompress
}
It will recreate Stellar logs every day while keeping history for only 2 last days. Rotated logs will be additionally compressed.
Not sure what you mean by "according to time", but see if the following helps.
Restarting Stellar-Core will let it start with a new log file, and your old log file will not grow again. Then you may move the big old file to offline storage.
If you stop Core and start it again within 3 seconds, most likely it will be still in the state of "Sync".
If you mean that your log is being too verbose and detailed, then consider tuning the log level:
Log messages are classified by progressive priority levels: TRACE, DEBUG, INFO, WARNING, ERROR and FATAL. https://www.stellar.org/developers/stellar-core/software/admin.html#logging
The default should be INFO. For a more concise log, consider Stellar-Core with llevel=WARNING (or ERROR).
This can be achieved with starting Core with a flag, like: $ stellar-core -c "ll?level=WARNING"
, or as a field like COMMANDS=["ll?level=info"]
in stellar-core.cfg
Note: New settings will not apply until you restart Core.
You can use tools like logrotate to rotate existing and expose of old logs.
You can use fluentd to process and grok your logs, and send them to any output like Elasticsearch or Datadog or anything basically (check out the possible plugins).
You can use Kibana and/or Grafana to display statistics and dashboards about your logs.