@@ -4,6 +4,7 @@
# loglevel = [VERBOSE,DEBUG,INFO,WARN,ERROR,FATAL,SILENT]
loglevel = INFO
log_remain_days = 3
+log_filesize = 16M
# worker_processes = 4
# auto = ncpu
loglevel = DEBUG
@@ -92,6 +92,27 @@ int parse_confile(const char* confile) {
g_conf_ctx.loglevel = LOG_LEVEL_VERBOSE;
}
hlog_set_level(g_conf_ctx.loglevel);
+ // log_filesize
+ str = g_conf_ctx.parser->GetValue("log_filesize");
+ if (!str.empty()) {
+ int num = atoi(str.c_str());
+ if (num > 0) {
+ // 16 16M 16MB
+ const char* p = str.c_str() + str.size() - 1;
+ char unit;
+ if (*p >= '0' && *p <= '9') unit = 'M';
+ else if (*p == 'B') unit = *(p-1);
+ else unit = *p;
+ unsigned long long filesize = num;
+ switch (unit) {
+ case 'K': filesize <<= 10; break;
+ case 'M': filesize <<= 20; break;
+ case 'G': filesize <<= 30; break;
+ default: filesize <<= 20; break;
+ }
+ hlog_set_max_filesize(filesize);
// log_remain_days
str = g_conf_ctx.parser->GetValue("log_remain_days");
if (!str.empty()) {