[lxc-devel] [PATCH 1/1] ubuntu templates: send logs to /var/log/lxc/$name.log by default

Stéphane Graber stgraber at ubuntu.com
Mon Jan 14 20:33:10 UTC 2013


On 01/14/2013 03:24 PM, Serge Hallyn wrote:
> (leave the level at the current default)
> 
> Is there a better way to go about this?  Should we set a default directory
> in /etc/default/lxc or at build-time, and allways use
> ${LXC_LOG_PATH}/${name}.log?  Should lxc-create do this for all containers,
> or should we do it through the templates as I did here?

Assuming the various template maintainers agree, I think it'd be best to
have a LXC_LOG_PATH defined in the configure, that should at least let
you drop the mkdir call.

I think it'd also be best to have lxc-start assume logging into
/var/log/lxc/<container name>.log by default and only use lxc.logfile as
an override of that.
That way existing containers will also be logged at the right place
without requiring the admin to update all the configs.

The log level should still be kept to its current value as we don't want
to end up creating a ton of big log files that nobody will read ;)
We just want those to be useful when something goes wrong.

> Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
> ---
>  templates/lxc-ubuntu-cloud.in | 4 ++++
>  templates/lxc-ubuntu.in       | 4 ++++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/templates/lxc-ubuntu-cloud.in b/templates/lxc-ubuntu-cloud.in
> index de9f3c3..bbdbf78 100644
> --- a/templates/lxc-ubuntu-cloud.in
> +++ b/templates/lxc-ubuntu-cloud.in
> @@ -47,9 +47,13 @@ EOF
>      fi
>  
>      grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config
> +    if [ ! -d /var/log/lxc ]; then
> +        mkdir /var/log/lxc
> +    fi
>      cat <<EOF >> $path/config
>  lxc.utsname = $name
>  
> +lxc.logfile = /var/log/lxc/$name.log
>  lxc.tty = 4
>  lxc.pts = 1024
>  lxc.mount = $path/fstab
> diff --git a/templates/lxc-ubuntu.in b/templates/lxc-ubuntu.in
> index 0ed8808..3a6c21d 100644
> --- a/templates/lxc-ubuntu.in
> +++ b/templates/lxc-ubuntu.in
> @@ -325,9 +325,13 @@ EOF
>      fi
>  
>      grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config
> +    if [ ! -d /var/log/lxc ]; then
> +        mkdir /var/log/lxc
> +    fi
>      cat <<EOF >> $path/config
>  lxc.utsname = $name
>  
> +lxc.logfile = /var/log/lxc/$name.log
>  lxc.devttydir =$ttydir
>  lxc.tty = 4
>  lxc.pts = 1024
> 


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20130114/75d849da/attachment.pgp>


More information about the lxc-devel mailing list