[Kimchi-devel] [PATCH 1/2 - v2][wok] Limit number of backup log files and make it configurable

Aline Manera alinefm at linux.vnet.ibm.com
Wed Jan 13 14:31:43 UTC 2016


Hi Rodrigo,

Is there an option to allow log compression? It would be good to have it 
too as requested in the issue 
https://github.com/kimchi-project/wok/issues/26

Or has it already been doing in some way?

Regards,
Aline Manera

On 01/13/2016 10:11 AM, Rodrigo Trujillo wrote:
> Currently Wok is configured to keep up to 1000 log files of 10MB, this
> behavior makes Wok/Kimchi log space become huge (up to 20GB, for error
> and access logs).
> This patch changes the configuration, limiting the number of stored log
> files to 10. So space required in the system will be up to 200MB.
>
> It also adds log_backup_count property to /etc/wok.conf, allowing users
> to change this value if necessary.
>
> Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
> ---
>   src/wok.conf.in      | 3 +++
>   src/wok/config.py.in | 2 ++
>   src/wok/server.py    | 6 ++++--
>   src/wokd.in          | 2 ++
>   4 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/src/wok.conf.in b/src/wok.conf.in
> index 60d826f..5e86ff8 100644
> --- a/src/wok.conf.in
> +++ b/src/wok.conf.in
> @@ -43,6 +43,9 @@
>   # Logging level: debug, info, warning, error or critical
>   #log_level = debug
>
> +# Log files backup count. The number of old log files to keep in the system
> +# log_backup_count = 10
> +
>   [display]
>   # Port for websocket proxy to listen on
>   #display_proxy_port = 64667
> diff --git a/src/wok/config.py.in b/src/wok/config.py.in
> index 0c83812..342e80b 100644
> --- a/src/wok/config.py.in
> +++ b/src/wok/config.py.in
> @@ -29,6 +29,7 @@ __release__ = "@wokrelease@"
>
>   CACHEEXPIRES = 31536000     # expires is one year.
>   DEFAULT_LOG_LEVEL = "debug"
> +DEFAULT_LOG_BACKUP_COUNT = 10
>
>   FONT_FILES = {'fontawesome': ['fontawesome-webfont.ttf'],
>                 'opensans': ['OpenSans-ExtraBoldItalic.ttf',
> @@ -247,6 +248,7 @@ def _get_config():
>       config.add_section("logging")
>       config.set("logging", "log_dir", paths.log_dir)
>       config.set("logging", "log_level", DEFAULT_LOG_LEVEL)
> +    config.set("logging", "log_backup_count", str(DEFAULT_LOG_BACKUP_COUNT))
>       config.add_section("display")
>       config.set("display", "display_proxy_port", "64667")
>
> diff --git a/src/wok/server.py b/src/wok/server.py
> index 59ecdc0..53af12a 100644
> --- a/src/wok/server.py
> +++ b/src/wok/server.py
> @@ -101,7 +101,8 @@ class Server(object):
>
>           # Create handler to rotate access log file
>           h = logging.handlers.RotatingFileHandler(options.access_log, 'a',
> -                                                 10000000, 1000)
> +                                                 10000000,
> +                                                 options.log_backup_count)
>           h.setLevel(logLevel)
>           h.setFormatter(cherrypy._cplogging.logfmt)
>
> @@ -110,7 +111,8 @@ class Server(object):
>
>           # Create handler to rotate error log file
>           h = logging.handlers.RotatingFileHandler(options.error_log, 'a',
> -                                                 10000000, 1000)
> +                                                 10000000,
> +                                                 options.log_backup_count)
>           h.setLevel(logLevel)
>           h.setFormatter(cherrypy._cplogging.logfmt)
>
> diff --git a/src/wokd.in b/src/wokd.in
> index c5510fd..ac43df6 100644
> --- a/src/wokd.in
> +++ b/src/wokd.in
> @@ -94,6 +94,8 @@ def main(options):
>       setattr(options, 'ssl_key', config.config.get('server', 'ssl_key'))
>       setattr(options, 'max_body_size',
>               config.config.get('server', 'max_body_size'))
> +    setattr(options, 'log_backup_count',
> +            config.config.get('logging', 'log_backup_count'))
>
>       wok.server.main(options)
>




More information about the Kimchi-devel mailing list