diff --git a/doc/icecast2_config_file.html b/doc/icecast2_config_file.html
index 525ced74..e7570c5a 100644
--- a/doc/icecast2_config_file.html
+++ b/doc/icecast2_config_file.html
@@ -641,6 +641,18 @@ All icecast generated log messages will be written to this file. If the logleve
Into this file, a log of all metadata for each mountpoint will be written. The format of the logfile will most likely change over time as we narrow in on a standard format for this. Currently, the file is pipe delimited. This option is optional and can be removed entirely from the config file.
+logsize
+
+This value specifies (in Kbytes) the maxmimum size of any of the log files. When the logfile grows beyond this value,
+icecast will either rename it to logfile.old, or add a timestamp to the archived file (if logarchive is enabled).
+
+logarchive
+
+If this value is set, then icecast will append a timestamp to the end of the logfile name when logsize has been reached.
+If disabled, then the default behavior is to rename the logfile to logfile.old (overwriting any previously saved
+logfiles). We disable this by default to prevent the filling up of filesystems for people who don't care (or know) that
+their logs are growing.
+
loglevel
Indicates what messages are logged by icecast. Log messages are categorized into one of 4 types, Debug, Info, Warn, and Error.
The following mapping can be used to set the appropraite value :
diff --git a/src/cfgfile.c b/src/cfgfile.c
index a14b09af..7e761f1b 100644
--- a/src/cfgfile.c
+++ b/src/cfgfile.c
@@ -948,10 +948,18 @@ static void _parse_logging(xmlDocPtr doc, xmlNodePtr node,
} else if (strcmp(node->name, "playlistlog") == 0) {
if (configuration->playlist_log && configuration->playlist_log != CONFIG_DEFAULT_PLAYLIST_LOG) xmlFree(configuration->playlist_log);
configuration->playlist_log = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+ } else if (strcmp(node->name, "logsize") == 0) {
+ char *tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+ configuration->logsize = atoi(tmp);
+ if (tmp) xmlFree(tmp);
} else if (strcmp(node->name, "loglevel") == 0) {
char *tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
configuration->loglevel = atoi(tmp);
if (tmp) xmlFree(tmp);
+ } else if (strcmp(node->name, "logarchive") == 0) {
+ char *tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+ configuration->logarchive = atoi(tmp);
+ if (tmp) xmlFree(tmp);
}
} while ((node = node->next));
}
diff --git a/src/cfgfile.h b/src/cfgfile.h
index 0800b6dc..a32c9f35 100644
--- a/src/cfgfile.h
+++ b/src/cfgfile.h
@@ -155,6 +155,8 @@ typedef struct ice_config_tag
char *error_log;
char *playlist_log;
int loglevel;
+ int logsize;
+ int logarchive;
int chroot;
int chuid;
diff --git a/src/logging.c b/src/logging.c
index 0d77947c..786e76cb 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -217,6 +217,8 @@ void restart_logging (ice_config_t *config)
snprintf (fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->error_log);
log_set_filename (errorlog, fn_error);
log_set_level (errorlog, config->loglevel);
+ log_set_trigger (errorlog, config->logsize);
+ log_set_archive_timestamp(errorlog, config->logarchive);
log_reopen (errorlog);
}
@@ -225,6 +227,8 @@ void restart_logging (ice_config_t *config)
char fn_error[FILENAME_MAX];
snprintf (fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->access_log);
log_set_filename (accesslog, fn_error);
+ log_set_trigger (errorlog, config->logsize);
+ log_set_archive_timestamp(errorlog, config->logarchive);
log_reopen (accesslog);
}
@@ -233,6 +237,8 @@ void restart_logging (ice_config_t *config)
char fn_error[FILENAME_MAX];
snprintf (fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->playlist_log);
log_set_filename (playlistlog, fn_error);
+ log_set_trigger (errorlog, config->logsize);
+ log_set_archive_timestamp(errorlog, config->logarchive);
log_reopen (playlistlog);
}
}
diff --git a/src/main.c b/src/main.c
index 79b793aa..401f3059 100644
--- a/src/main.c
+++ b/src/main.c
@@ -194,6 +194,9 @@ static int _start_logging(void)
snprintf(fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->error_log);
errorlog = log_open(fn_error);
log_to_stderr = 0;
+ if (config->logsize)
+ log_set_trigger (errorlog, config->logsize);
+ log_set_archive_timestamp(errorlog, config->logarchive);
} else {
errorlog = log_open_file(stderr);
log_to_stderr = 1;
@@ -213,6 +216,9 @@ static int _start_logging(void)
snprintf(fn_access, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->access_log);
accesslog = log_open(fn_access);
log_to_stderr = 0;
+ if (config->logsize)
+ log_set_trigger (accesslog, config->logsize);
+ log_set_archive_timestamp(accesslog, config->logarchive);
} else {
accesslog = log_open_file(stderr);
log_to_stderr = 1;
@@ -239,6 +245,9 @@ static int _start_logging(void)
_fatal_error(buf);
}
log_to_stderr = 0;
+ if (config->logsize)
+ log_set_trigger (playlistlog, config->logsize);
+ log_set_archive_timestamp(playlistlog, config->logarchive);
} else {
playlistlog = -1;
}