]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Create log file in lxcpath for non-system containers
authorDwight Engen <dwight.engen@oracle.com>
Mon, 29 Apr 2013 18:54:08 +0000 (14:54 -0400)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Tue, 30 Apr 2013 13:20:17 +0000 (08:20 -0500)
On Fri, 26 Apr 2013 10:18:12 -0500
Serge Hallyn <serge.hallyn@ubuntu.com> wrote:

> Quoting Dwight Engen (dwight.engen@oracle.com):
> > On Fri, 26 Apr 2013 09:37:49 -0500
> > Serge Hallyn <serge.hallyn@ubuntu.com> wrote:
> >
> > > Quoting Dwight Engen (dwight.engen@oracle.com):
> > > > Using lxc configured with --enable-configpath-log, and
> > > > specifying a path to the lxc commands with -P, the log file
> > > > path is generated with a basename of LOGPATH instead of the
> > > > lxcpath. This means for example if you do
> > > >
> > > > lxc-start -P /tmp/containers -n test01 -l INFO
> > > >
> > > > your log file will be
> > > >
> > > > /var/lib/lxc/test01/test01.log
> > > >
> > > > I was expecting the log to be /tmp/containers/test01/test01.log.
> > > > This is particularly confusing if you also have test01 on the
> > > > regular lxcpath. The patch below changes the log file path to be
> > > > based on lxcpath rather than LOGPATH when lxc is configured with
> > > > --enable-configpath-log.
> > > >
> > > > I think that even in the normal non --enable-configpath-log case
> > > > we should consider using lxcpath as the base and not having
> > > > LOGPATH at all, as attempting to create the log files
> > > > in /var/log is not going to work for regular users on their own
> > > > lxcpath. If we want that, I'll update the patch to do that as
> > > > well.
> > >
> > >
> > > Perhaps we should do:
> > >
> > >  1. If lxcpath == default_lxc_path(), then first choice is
> > >     LOGPATH, second is lxcpath/container.log
> > >  2. when opening, if first choice fails, use second choice
> > >     if there is any.
> > >
> > > That way 'system' containers will go to /var/log/lxc, as I think
> > > they should.  Custom-lxcpath containers should never go
> > > to /var/log/lxc, since their names could be dups of containers in
> > > default_lxc_path(). And if the system is a weird one where
> > > default_lxc_path is set up so that an unprivileged user can use
> > > it, then we should log into $lxcpath.
> >
> > That sounds good to me. So these rules would apply in both the
> > regular and --enable-configpath-log cases.

I updated the patch to try to open the log file according to the
choices given above. Along the way I cleaned up log.c a bit, making
some things static, grouping external interfaces together, etc...
Hopefully that doesn't add too much noise.

> > > (Note this patch will trivially conflict with my new lxc_clone.c
> > > causing it to fail to build - unfortunate result of timing)
> >
> > Yeah unfortunately this touches every lxc_log_init() caller. I can
> > work on the above logic and re-submit after your new lxc_clone
> > stuff goes in.
>
> No no, I'll just need to remember to update mine.  Don't hold up on
> mine, this is just the nature of such collaboration  :)
>
> > Did you have any thoughts on the XXX what to pass in for lxcpath in
> > lxc_init? Right now it just falls back to LOGPATH.
>
> No - that's a weird one, since lxc_init runs in the container.  If
> there were only system containers I'd say always use LOGPATH.
> However there are people (apparently :) who use container sharing the
> host's rootfs...
>
> lxc-execute does know the lxcpath.  Perhaps we can simply have
> src/lxc/execute.c:execute_start() look at handler->conf to see if a
> rootfs is set.  If rootfs is NOT set, then pass lxcpath along to
> lxc-init.  Then lxc-init can mostly do the same as the others?  (It
> doesn't use src/lxc/arguments.c, so you'd have to add lxcpath to
> options[] in lxc-init.c)

So I did this, only to realize that lxc-init is passing "none" for the
file anyway, so it currently doesn't intend to log. This makes me
think that passing NULL for lxcpath is the right thing to do in
this patch. If you want me to make it so lxc-init can log, I can do
that but I think it should be in a different change :)

--

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
19 files changed:
src/lxc/log.c
src/lxc/log.h
src/lxc/lxc_attach.c
src/lxc/lxc_cgroup.c
src/lxc/lxc_checkpoint.c
src/lxc/lxc_console.c
src/lxc/lxc_execute.c
src/lxc/lxc_freeze.c
src/lxc/lxc_info.c
src/lxc/lxc_init.c
src/lxc/lxc_kill.c
src/lxc/lxc_monitor.c
src/lxc/lxc_monitord.c
src/lxc/lxc_restart.c
src/lxc/lxc_start.c
src/lxc/lxc_stop.c
src/lxc/lxc_unfreeze.c
src/lxc/lxc_wait.c
src/lxc/lxccontainer.c

index 3c6e4d1884c66ed3348372e0423d0721174d0c77..61280bc0b9233a9f545ada1578f5499b2fb0379d 100644 (file)
 
 #include "log.h"
 #include "caps.h"
+#include "utils.h"
 
 #define LXC_LOG_PREFIX_SIZE    32
 #define LXC_LOG_BUFFER_SIZE    512
 
 int lxc_log_fd = -1;
 static char log_prefix[LXC_LOG_PREFIX_SIZE] = "lxc";
+static char *log_fname = NULL;
+/* command line values for logfile or logpriority should always override
+ * values from the configuration file or defaults
+ */
+static int lxc_logfile_specified = 0;
 static int lxc_loglevel_specified = 0;
-// if logfile was specifed on command line, it won't be overridden by lxc.logfile
-static int lxc_log_specified = 0;
 
 lxc_log_define(lxc_log, lxc);
 
@@ -119,12 +123,6 @@ struct lxc_log_category lxc_log_category_lxc = {
 };
 
 /*---------------------------------------------------------------------------*/
-extern void lxc_log_setprefix(const char *prefix)
-{
-       strncpy(log_prefix, prefix, sizeof(log_prefix));
-       log_prefix[sizeof(log_prefix) - 1] = 0;
-}
-
 static int build_dir(const char *name)
 {
        char *n = strdup(name);  // because we'll be modifying it
@@ -180,28 +178,39 @@ static int log_open(const char *name)
        return newfd;
 }
 
-static char *build_log_path(const char *name)
+/*
+ * Build the path to the log file
+ * @name     : the name of the container
+ * @lxcpath  : the lxcpath to use as a basename or NULL to use LOGPATH
+ * Returns malloced path on sucess, or NULL on failure
+ */
+static char *build_log_path(const char *name, const char *lxcpath)
 {
        char *p;
        int len, ret;
 
        /*
-        * '$logpath' + '/' + '$name' + '.log' + '\0'
-        * or
+        * If USE_CONFIGPATH_LOGS is true the resulting path will be:
         * '$logpath' + '/' + '$name' + '/' + '$name' + '.log' + '\0'
-        * sizeof(LOGPATH) includes its \0
+        *
+        * If USE_CONFIGPATH_LOGS is false the resulting path will be:
+        * '$logpath' + '/' + '$name' + '.log' + '\0'
         */
-       len = sizeof(LOGPATH) + strlen(name) + 6;
+       len = strlen(name) + 6; /* 6 == '/' + '.log' + '\0' */
+       if (!lxcpath)
+               lxcpath = LOGPATH;
 #if USE_CONFIGPATH_LOGS
-       len += strlen(name) + 1;  /* add "/$container_name/" */
+       len += strlen(lxcpath) + 1 + strlen(name) + 1;  /* add "/$container_name/" */
+#else
+       len += strlen(lxcpath) + 1;
 #endif
        p = malloc(len);
        if (!p)
                return p;
 #if USE_CONFIGPATH_LOGS
-       ret = snprintf(p, len, "%s/%s/%s.log", LOGPATH, name, name);
+       ret = snprintf(p, len, "%s/%s/%s.log", lxcpath, name, name);
 #else
-       ret = snprintf(p, len, "%s/%s.log", LOGPATH, name);
+       ret = snprintf(p, len, "%s/%s.log", lxcpath, name);
 #endif
        if (ret < 0 || ret >= len) {
                free(p);
@@ -210,19 +219,67 @@ static char *build_log_path(const char *name)
        return p;
 }
 
-int do_lxc_log_set_file(const char *fname, int from_default);
+/*
+ * This can be called:
+ *   1. when a program calls lxc_log_init with no logfile parameter (in which
+ *      case the default is used).  In this case lxc.logfile can override this.
+ *   2. when a program calls lxc_log_init with a logfile parameter.  In this
+ *     case we don't want lxc.logfile to override this.
+ *   3. When a lxc.logfile entry is found in config file.
+ */
+static int __lxc_log_set_file(const char *fname, int create_dirs)
+{
+       if (lxc_log_fd != -1) {
+               // we are overriding the default.
+               close(lxc_log_fd);
+               free(log_fname);
+       }
+
+#if USE_CONFIGPATH_LOGS
+       // we don't build_dir for the default if the default is
+       // i.e. /var/lib/lxc/$container/$container.log
+       if (create_dirs)
+#endif
+       if (build_dir(fname)) {
+               ERROR("failed to create dir for log file \"%s\" : %s", fname,
+                     strerror(errno));
+               return -1;
+       }
+
+       lxc_log_fd = log_open(fname);
+       if (lxc_log_fd == -1)
+               return -1;
+
+       log_fname = strdup(fname);
+       return 0;
+}
+
+static int _lxc_log_set_file(const char *name, const char *lxcpath, int create_dirs)
+{
+       char *logfile;
+       int ret;
+
+       logfile = build_log_path(name, lxcpath);
+       if (!logfile) {
+               ERROR("could not build log path");
+               return -1;
+       }
+       ret = __lxc_log_set_file(logfile, create_dirs);
+       free(logfile);
+       return ret;
+}
 
-/*---------------------------------------------------------------------------*/
 extern int lxc_log_init(const char *name, const char *file,
-                       const char *priority, const char *prefix, int quiet)
+                       const char *priority, const char *prefix, int quiet,
+                       const char *lxcpath)
 {
        int lxc_priority = LXC_LOG_PRIORITY_ERROR;
        int ret;
-       char *tmpfile = NULL;
-       int want_lxc_log_specified = 0;
 
-       if (lxc_log_fd != -1)
+       if (lxc_log_fd != -1) {
+               WARN("lxc_log_init called with log already initialized");
                return 0;
+       }
 
        if (priority) {
                lxc_loglevel_specified = 1;
@@ -241,38 +298,38 @@ extern int lxc_log_init(const char *name, const char *file,
                lxc_log_category_lxc.appender->next = &log_appender_stderr;
 
        if (prefix)
-               lxc_log_setprefix(prefix);
-
-       if (file && strcmp(file, "none") == 0) {
-               return 0;
-       }
+               lxc_log_set_prefix(prefix);
 
-       if (!file) {
-               tmpfile = build_log_path(name);
-               if (!tmpfile) {
-                       ERROR("could not build log path");
-                       return -1;
-               }
+       if (file) {
+               lxc_logfile_specified = 1;
+               if (strcmp(file, "none") == 0)
+                       return 0;
+               ret = __lxc_log_set_file(file, 1);
        } else {
-               want_lxc_log_specified = 1;
-       }
+               ret = -1;
+
+               /* try LOGPATH if lxcpath is the default */
+               if (strcmp(lxcpath, default_lxc_path()) == 0)
+                       ret = _lxc_log_set_file(name, NULL, 0);
 
-       ret = do_lxc_log_set_file(tmpfile ? tmpfile : file, !want_lxc_log_specified);
+               /* try in lxcpath */
+               if (ret < 0)
+                       ret = _lxc_log_set_file(name, lxcpath, 1);
+
+               /* try LOGPATH in case its writable by the caller */
+               if (ret < 0)
+                       ret = _lxc_log_set_file(name, NULL, 0);
+       }
 
-       if (want_lxc_log_specified)
-               lxc_log_specified = 1;
        /*
-        * If !want_lxc_log_specified, that is, if the user did not request
-        * this logpath, then ignore failures and continue logging to console
+        * If !file, that is, if the user did not request this logpath, then
+        * ignore failures and continue logging to console
         */
-       if (!want_lxc_log_specified && ret != 0) {
+       if (!file && ret != 0) {
                INFO("Ignoring failure to open default logfile.");
                ret = 0;
        }
 
-       if (tmpfile)
-               free(tmpfile);
-
        return ret;
 }
 
@@ -293,59 +350,37 @@ extern int lxc_log_set_level(int level)
        return 0;
 }
 
-char *log_fname;  // default to NULL, set in lxc_log_set_file.
+extern int lxc_log_get_level(void)
+{
+       if (!lxc_loglevel_specified)
+               return LXC_LOG_PRIORITY_NOTSET;
+       return lxc_log_category_lxc.priority;
+}
+
 /*
- * This can be called:
- *   1. when a program calls lxc_log_init with no logfile parameter (in which
- *      case the default is used).  In this case lxc.logfile can override this.
- *   2. when a program calls lxc_log_init with a logfile parameter.  In this
- *     case we don't want lxc.logfile to override this.
- *   3. When a lxc.logfile entry is found in config file.
+ * This is called when we read a lxc.logfile entry in a lxc.conf file.  This
+ * happens after processing command line arguments, which override the .conf
+ * settings.  So only set the file if previously unset.
  */
-int do_lxc_log_set_file(const char *fname, int from_default)
+extern int lxc_log_set_file(const char *fname)
 {
-       if (lxc_log_specified) {
-               INFO("lxc.logfile overridden by command line");
+       if (lxc_logfile_specified)
                return 0;
-       }
-       if (lxc_log_fd != -1) {
-               // we are overriding the default.
-               close(lxc_log_fd);
-               free(log_fname);
-       }
-
-#if USE_CONFIGPATH_LOGS
-       // we don't build_dir for the default if the default is
-       // i.e. /var/lib/lxc/$container/$container.log
-       if (!from_default)
-#endif
-       if (build_dir(fname)) {
-               ERROR("failed to create dir for log file \"%s\" : %s", fname,
-                     strerror(errno));
-               return -1;
-       }
-
-       lxc_log_fd = log_open(fname);
-       if (lxc_log_fd == -1)
-               return -1;
-
-       log_fname = strdup(fname);
-       return 0;
+       return __lxc_log_set_file(fname, 0);
 }
 
-extern int lxc_log_set_file(const char *fname)
+extern const char *lxc_log_get_file(void)
 {
-       return do_lxc_log_set_file(fname, 0);
+       return log_fname;
 }
 
-extern int lxc_log_get_level(void)
+extern void lxc_log_set_prefix(const char *prefix)
 {
-       if (!lxc_loglevel_specified)
-               return LXC_LOG_PRIORITY_NOTSET;
-       return lxc_log_category_lxc.priority;
+       strncpy(log_prefix, prefix, sizeof(log_prefix));
+       log_prefix[sizeof(log_prefix) - 1] = 0;
 }
 
-extern const char *lxc_log_get_file(void)
+extern const char *lxc_log_get_prefix(void)
 {
-       return log_fname;
+       return log_prefix;
 }
index cd43068a80e8acfdb3795ba9fc4355f3d0c2f8a4..2fd40500041c8d45a19d48d275b72fb957b36fcd 100644 (file)
@@ -288,11 +288,13 @@ extern struct lxc_log_category lxc_log_category_lxc;
 extern int lxc_log_fd;
 
 extern int lxc_log_init(const char *name, const char *file,
-                       const char *priority, const char *prefix, int quiet);
+                       const char *priority, const char *prefix, int quiet,
+                       const char *lxcpath);
 
-extern void lxc_log_setprefix(const char *a_prefix);
-extern int lxc_log_set_level(int level);
 extern int lxc_log_set_file(const char *fname);
-extern int lxc_log_get_level(void);
+extern int lxc_log_set_level(int level);
+extern void lxc_log_set_prefix(const char *prefix);
 extern const char *lxc_log_get_file(void);
+extern int lxc_log_get_level(void);
+extern const char *lxc_log_get_prefix(void);
 #endif
index d845e3c48cbe7c878487ad664cad9662d3afcac5..300bc922d40a6fe08f6992d9433b1ee5f9c5cc05 100644 (file)
@@ -292,7 +292,7 @@ int main(int argc, char *argv[])
                return ret;
 
        ret = lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
-                          my_args.progname, my_args.quiet);
+                          my_args.progname, my_args.quiet, my_args.lxcpath);
        if (ret)
                return ret;
 
index f7c88a89cf2b742cda020957a694a543d9ded92a..7684f1b1f1c1bce1b195f3516089830aca6cb6a1 100644 (file)
@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
                return -1;
 
        if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
-                        my_args.progname, my_args.quiet))
+                        my_args.progname, my_args.quiet, my_args.lxcpath))
                return -1;
 
        state_object = my_args.argv[0];
index 947d9d941a236f30ae7ef0a4247edafb478b906f..8b3a02abe96204686b14a2de60c1f6d2dc9b6762 100644 (file)
@@ -116,7 +116,7 @@ int main(int argc, char *argv[])
                return ret;
 
        ret = lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
-                          my_args.progname, my_args.quiet);
+                          my_args.progname, my_args.quiet, my_args.lxcpath);
        if (ret)
                return ret;
 
index f6659f64e8460fa48a89ffd1faccf942cfbf7221..1d779a1612c338b5469f13b0d70e991c6d7717d1 100644 (file)
@@ -192,7 +192,7 @@ int main(int argc, char *argv[])
                return -1;
 
        err = lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
-                          my_args.progname, my_args.quiet);
+                          my_args.progname, my_args.quiet, my_args.lxcpath);
        if (err)
                return -1;
 
index 41e29aa9bf4b713760eb620a9b356fc514f942b0..0fa2d2516a71e43ffaade2f40ffb6c13f8db0a33 100644 (file)
@@ -101,7 +101,7 @@ int main(int argc, char *argv[])
                return -1;
 
        if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
-                        my_args.progname, my_args.quiet))
+                        my_args.progname, my_args.quiet, my_args.lxcpath))
                return -1;
 
        /* rcfile is specified in the cli option */
index b52ab5bf1eb29a79a19effdf650febfe58f7f44c..ff3cdd5778aaae8fa01eaf00b479eb68e3ef8bf4 100644 (file)
@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
                return -1;
 
        if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
-                        my_args.progname, my_args.quiet))
+                        my_args.progname, my_args.quiet, my_args.lxcpath))
                return -1;
 
        return lxc_freeze(my_args.name, my_args.lxcpath);
index 3fcead583dfa600dad0419c89090ed72e5ab3302..b19b1d02f13ebdaee050adb66e3be752de559d84 100644 (file)
@@ -80,7 +80,7 @@ int main(int argc, char *argv[])
                return 1;
 
        if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
-                        my_args.progname, my_args.quiet))
+                        my_args.progname, my_args.quiet, my_args.lxcpath))
                return 1;
 
        if (!state && !pid)
index 84e12932ee8a2d406fb3e8d21b207f1badc88c48..663875b370d8e4e00b7fb27871cc8656e88b0507 100644 (file)
@@ -78,7 +78,7 @@ int main(int argc, char *argv[])
        if (lxc_caps_init())
                exit(err);
 
-       if (lxc_log_init(NULL, "none", 0, basename(argv[0]), quiet))
+       if (lxc_log_init(NULL, "none", 0, basename(argv[0]), quiet, NULL))
                exit(err);
 
        if (!argv[optind]) {
index ba00aa8c15995dd41f9f2265e3ac6fea9aaf0e63..e08993139f7f691694b417f603b86f70d49f9988 100644 (file)
@@ -62,7 +62,7 @@ int main(int argc, char *argv[], char *envp[])
                return ret;
 
        ret = lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
-                          my_args.progname, my_args.quiet);
+                          my_args.progname, my_args.quiet, my_args.lxcpath);
        if (ret)
                return ret;
 
index 0ca829f6775f96971d29e40dfb19b76b746513f6..5ddb2913a681e3e4a250e34ab60ff4a75ab2ebef 100644 (file)
@@ -66,7 +66,7 @@ int main(int argc, char *argv[])
                return -1;
 
        if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
-                        my_args.progname, my_args.quiet))
+                        my_args.progname, my_args.quiet, my_args.lxcpath))
                return -1;
 
        len = strlen(my_args.name) + 3;
index 3b5cf53b19eb9b1bcc0fe7984facc86e1c261a89..e76af716b5ce77380da8ae209c2cf84bf6187b09 100644 (file)
@@ -343,7 +343,7 @@ int main(int argc, char *argv[])
        if (ret < 0 || ret >= sizeof(logpath))
                return EXIT_FAILURE;
 
-       ret = lxc_log_init(NULL, logpath, "NOTICE", "lxc-monitord", 0);
+       ret = lxc_log_init(NULL, logpath, "NOTICE", "lxc-monitord", 0, lxcpath);
        if (ret)
                return ret;
 
index 118d4b8798049407cc9910bfc1ed50c490b4b354..77099b14907cf371ff78707ae2a67976fd6f0cf3 100644 (file)
@@ -124,7 +124,7 @@ int main(int argc, char *argv[])
                return -1;
 
        if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
-                        my_args.progname, my_args.quiet))
+                        my_args.progname, my_args.quiet, my_args.lxcpath))
                return -1;
 
        /* rcfile is specified in the cli option */
index 957fdb0e7b0095d37b5eac683905b3f075f164cf..d923a7eb5fbadf8dcac9e2d9209b45e67a61e349 100644 (file)
@@ -165,7 +165,7 @@ int main(int argc, char *argv[])
                args = my_args.argv;
 
        if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
-                        my_args.progname, my_args.quiet))
+                        my_args.progname, my_args.quiet, my_args.lxcpath))
                return err;
 
        /* rcfile is specified in the cli option */
index b4d9f23dd2eb158c2d20a6d46d66e832dc4b7732..0967a156f8cbbfda272159cab5b233f8bab8bcfc 100644 (file)
@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
                return -1;
 
        if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
-                        my_args.progname, my_args.quiet))
+                        my_args.progname, my_args.quiet, my_args.lxcpath))
                return -1;
 
        return lxc_stop(my_args.name, my_args.lxcpath);
index 0bb5dc502aa7ef64137a9652e2421bbf2a9d6494..44d3cc02116266b1c70b26dad6e0f05c05a7ed99 100644 (file)
@@ -54,7 +54,7 @@ int main(int argc, char *argv[])
                return -1;
 
        if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
-                        my_args.progname, my_args.quiet))
+                        my_args.progname, my_args.quiet, my_args.lxcpath))
                return -1;
 
        return lxc_unfreeze(my_args.name, my_args.lxcpath);
index 18200e5740fdcc54ba416a3bc2eea63fd2e579fc..d21578b6c5950e74d46251c813e6c187c3aeaba8 100644 (file)
@@ -84,7 +84,7 @@ int main(int argc, char *argv[])
                return -1;
 
        if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
-                        my_args.progname, my_args.quiet))
+                        my_args.progname, my_args.quiet, my_args.lxcpath))
                return -1;
 
        return lxc_wait(strdup(my_args.name), my_args.states, my_args.timeout, my_args.lxcpath);
index 53765b04cd64c00821f75a2315916a86469ce949..740a8d99eed7133c3b03624761a844690a261aef 100644 (file)
@@ -1105,7 +1105,7 @@ struct lxc_container *lxc_container_new(const char *name, const char *configpath
        c->set_config_path = lxcapi_set_config_path;
 
        /* we'll allow the caller to update these later */
-       if (lxc_log_init(NULL, "none", NULL, "lxc_container", 0)) {
+       if (lxc_log_init(NULL, "none", NULL, "lxc_container", 0, c->config_path)) {
                fprintf(stderr, "failed to open log\n");
                goto err;
        }