Hi Rodrigo,
i've got a problem using FileHandler, because after logrotate changes
the filename, this handler cannot create a new file to keep writing. So,
my strategy is to keep your code with "RotatingFileHandler" and just use
logrotate to compress it.
On 01/19/2016 05:40 PM, Rodrigo Trujillo wrote:
I have some concerns:
- You have set the log file size to 1024K (1 MB), and in Kimchi , the
original size is 10MB;
- Once we are compressing, we could have more than 10 backuped files;
- I think you must change the handlers in src/wok/server.py , I would
change from "RotatingFileHandler" to "FileHandler" only.
More information here:
https://docs.python.org/2/library/logging.handlers.html and here:
http://docs.cherrypy.org/en/3.2.6/refman/_cplogging.html#custom-handlers
On 01/14/2016 05:26 PM, Ramon Medeiros wrote:
> Use logrotate to compress and keep 10 logs of 1MB
>
> Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
> ---
>
> Changes:
>
> v2:
> Add logrotate as dependency
> Fix typo in Copyright
>
>
> Makefile.am | 2 ++
> contrib/DEBIAN/control.in | 1 +
> contrib/Makefile.am | 1 +
> contrib/wok.spec.fedora.in | 2 ++
> contrib/wok.spec.suse.in | 2 ++
> contrib/wokd.logrotate | 28 ++++++++++++++++++++++++++++
> 6 files changed, 36 insertions(+)
> create mode 100644 contrib/wokd.logrotate
>
> diff --git a/Makefile.am b/Makefile.am
> index 278bda1..6d4c574 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -140,6 +140,8 @@ install-data-local:
> mkdir -p $(DESTDIR)/etc/wok/
> $(INSTALL_DATA) src/dhparams.pem $(DESTDIR)/etc/wok/dhparams.pem
> touch $(DESTDIR)/etc/nginx/conf.d/wok.conf
> + mkdir -p $(DESTDIR)/etc/logrotate.d/
> + $(INSTALL_DATA) $(top_srcdir)/contrib/wokd.logrotate
> $(DESTDIR)/etc/logrotate.d/wokd
>
> uninstall-local:
> @if test -f $(systemdsystemunitdir)/wokd.service; then \
> diff --git a/contrib/DEBIAN/control.in b/contrib/DEBIAN/control.in
> index 1f39ad8..e585080 100644
> --- a/contrib/DEBIAN/control.in
> +++ b/contrib/DEBIAN/control.in
> @@ -14,6 +14,7 @@ Depends: python-cherrypy3 (>= 3.2.0),
> python-ldap,
> python-psutil (>= 0.6.0),
> fonts-font-awesome,
> + logrotate,
> texlive-fonts-extra
> Build-Depends: xsltproc,
> gettext,
> diff --git a/contrib/Makefile.am b/contrib/Makefile.am
> index ed4a006..2939bc9 100644
> --- a/contrib/Makefile.am
> +++ b/contrib/Makefile.am
> @@ -29,6 +29,7 @@ EXTRA_DIST = \
> wokd-upstart.conf.debian \
> wokd-upstart.conf.fedora \
> make-deb.sh.in \
> + wokd.logrotate \
> $(NULL)
>
> make-deb.sh: make-deb.sh.in $(top_builddir)/config.status
> diff --git a/contrib/wok.spec.fedora.in b/contrib/wok.spec.fedora.in
> index 34b3ac3..5501a20 100644
> --- a/contrib/wok.spec.fedora.in
> +++ b/contrib/wok.spec.fedora.in
> @@ -19,6 +19,7 @@ Requires: python-ldap
> Requires: python-psutil >= 0.6.0
> Requires: fontawesome-fonts
> Requires: open-sans-fonts
> +Requires: logrotate
> BuildRequires: gettext-devel
> BuildRequires: libxslt
> BuildRequires: openssl
> @@ -116,6 +117,7 @@ rm -rf $RPM_BUILD_ROOT
> %{_sysconfdir}/nginx/conf.d/wok.conf.in
> %{_sysconfdir}/wok/wok.conf
> %{_sysconfdir}/wok/
> +%{_sysconfdir}/logrotate.d/wokd
> %{_mandir}/man8/wokd.8.gz
>
> %if 0%{?with_systemd}
> diff --git a/contrib/wok.spec.suse.in b/contrib/wok.spec.suse.in
> index aab4a80..20d7138 100644
> --- a/contrib/wok.spec.suse.in
> +++ b/contrib/wok.spec.suse.in
> @@ -20,6 +20,7 @@ Requires: nginx
> Requires: python-psutil >= 0.6.0
> Requires: fontawesome-fonts
> Requires: google-opensans-fonts
> +Requires: logrotate
> BuildRequires: gettext-tools
> BuildRequires: libxslt-tools
> BuildRequires: openssl
> @@ -93,6 +94,7 @@ rm -rf $RPM_BUILD_ROOT
> %{_sysconfdir}/wok/
> %{_sysconfdir}/nginx/conf.d/wok.conf.in
> %{_sysconfdir}/nginx/conf.d/wok.conf
> +%{_sysconfdir}/logrotate.d/wokd
> %{_var}/lib/wok/
> %{_localstatedir}/log/wok/*
> %{_localstatedir}/log/wok/
> diff --git a/contrib/wokd.logrotate b/contrib/wokd.logrotate
> new file mode 100644
> index 0000000..0bf575f
> --- /dev/null
> +++ b/contrib/wokd.logrotate
> @@ -0,0 +1,28 @@
> +#
> +# Project Wok
> +#
> +# Copyright IBM Corp, 2016
> +#
> +# This library is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU Lesser General Public
> +# License as published by the Free Software Foundation; either
> +# version 2.1 of the License, or (at your option) any later version.
> +#
> +# This library is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> +# Lesser General Public License for more details.
> +#
> +# You should have received a copy of the GNU Lesser General Public
> +# License along with this library; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> +
> +/var/log/wok/*log {
> + daily
> + maxsize 1024k
> + rotate 10
> + missingok
> + compress
> + sharedscripts
> +}
> +
--
Ramon Nunes Medeiros
Kimchi Developer
Linux Technology Center Brazil
IBM Systems & Technology Group
Phone : +55 19 2132 7878
ramonn(a)br.ibm.com