mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
logging: add configuration for future log cleaner
We want to specify the folder to clean and how much time can a log chain live. Signed-off-by: Oleg Vasilev <oleg.vasilev@virtuozzo.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
673f22159d
commit
e69a3d1a79
@ -28,6 +28,7 @@
|
||||
#include "virutil.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_CONF
|
||||
#define DEFAULT_LOG_ROOT LOCALSTATEDIR "/log/libvirt/"
|
||||
|
||||
VIR_LOG_INIT("logging.log_daemon_config");
|
||||
|
||||
@ -60,6 +61,7 @@ virLogDaemonConfigNew(bool privileged G_GNUC_UNUSED)
|
||||
data->admin_max_clients = 5000;
|
||||
data->max_size = 1024 * 1024 * 2;
|
||||
data->max_backups = 3;
|
||||
data->max_age_days = 0;
|
||||
|
||||
return data;
|
||||
}
|
||||
@ -72,6 +74,7 @@ virLogDaemonConfigFree(virLogDaemonConfig *data)
|
||||
|
||||
g_free(data->log_filters);
|
||||
g_free(data->log_outputs);
|
||||
g_free(data->log_root);
|
||||
|
||||
g_free(data);
|
||||
}
|
||||
@ -94,6 +97,12 @@ virLogDaemonConfigLoadOptions(virLogDaemonConfig *data,
|
||||
return -1;
|
||||
if (virConfGetValueSizeT(conf, "max_backups", &data->max_backups) < 0)
|
||||
return -1;
|
||||
if (virConfGetValueSizeT(conf, "max_age_days", &data->max_age_days) < 0)
|
||||
return -1;
|
||||
if (virConfGetValueString(conf, "log_root", &data->log_root) < 0)
|
||||
return -1;
|
||||
if (!data->log_root)
|
||||
data->log_root = g_strdup(DEFAULT_LOG_ROOT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -33,6 +33,9 @@ struct _virLogDaemonConfig {
|
||||
|
||||
size_t max_backups;
|
||||
size_t max_size;
|
||||
|
||||
char *log_root;
|
||||
size_t max_age_days;
|
||||
};
|
||||
|
||||
|
||||
|
@ -9,3 +9,5 @@ module Test_virtlogd =
|
||||
{ "admin_max_clients" = "5" }
|
||||
{ "max_size" = "2097152" }
|
||||
{ "max_backups" = "3" }
|
||||
{ "max_age_days" = "0" }
|
||||
{ "log_root" = "/var/log/libvirt" }
|
||||
|
@ -31,6 +31,8 @@ module Virtlogd =
|
||||
| int_entry "admin_max_clients"
|
||||
| int_entry "max_size"
|
||||
| int_entry "max_backups"
|
||||
| int_entry "max_age_days"
|
||||
| str_entry "log_root"
|
||||
|
||||
(* Each entry in the config is one of the following three ... *)
|
||||
let entry = logging_entry
|
||||
|
@ -101,3 +101,17 @@
|
||||
# Maximum number of backup files to keep. Defaults to 3,
|
||||
# not including the primary active file
|
||||
#max_backups = 3
|
||||
|
||||
# Maximum age for log files to live after the last modification.
|
||||
# Defaults to 0, which means "forever".
|
||||
#
|
||||
# WARNING: since virtlogd has no way to differentiate which files it used to
|
||||
# manage, the garbage collection mechanism will collect ALL files, once its age
|
||||
# reach max_age_days. Use only if you know what you mean.
|
||||
#max_age_days = 0
|
||||
|
||||
# Root of all logs managed by virtlogd. Used to GC logs from obsolete machines.
|
||||
#
|
||||
# WARNING: all files under this location potentially can be GC-ed. See the
|
||||
# warning for max_age_days.
|
||||
#log_root = "/var/log/libvirt"
|
||||
|
Loading…
Reference in New Issue
Block a user