diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 228c4af..c2f63e6 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -95,7 +95,7 @@ struct domain {
 	int master_fd;
 	int master_pollfd_idx;
 	int slave_fd;
-	int log_fd;
+	struct logfile *log;
 	bool is_dead;
 	unsigned last_seen;
 	struct buffer buffer;
@@ -137,8 +137,9 @@ static int write_logfile(struct logfile *logfile, const char *buf,
 	return 0;
 }
 
-static int write_with_timestamp(int fd, const char *data, size_t sz,
-				int *needts)
+static  __attribute__((unused))
+int write_with_timestamp(int fd, const char *data, size_t sz,
+			 int *needts)
 {
 	char ts[32];
 	time_t now = time(NULL);
@@ -235,16 +236,16 @@ static void buffer_append(struct domain *dom)
 	 * no one is listening on the console pty then it will fill up
 	 * and handle_tty_write will stop being called.
 	 */
-	if (dom->log_fd != -1) {
+	if (dom->log) {
 		int logret;
 		if (log_time_guest) {
-			logret = write_with_timestamp(
-				dom->log_fd,
+			logret = write_logfile_with_timestamp(
+				dom->log,
 				buffer->data + buffer->size - size,
 				size, &log_time_guest_needts);
 		} else {
-			logret = write_all(
-				dom->log_fd,
+			logret = write_logfile(
+				dom->log,
 				buffer->data + buffer->size - size,
 				size);
 		}
@@ -336,50 +337,53 @@ static struct logfile *create_hv_log(void)
 	return tmp;
 }
 
-static int create_domain_log(struct domain *dom)
+static struct logfile *create_domain_log(struct domain *dom)
 {
 	char logfile[PATH_MAX];
 	char *namepath, *data, *s;
-	int fd;
 	unsigned int len;
+	struct logfile *tmp;
 
 	namepath = xs_get_domain_path(xs, dom->domid);
 	s = realloc(namepath, strlen(namepath) + 6);
 	if (s == NULL) {
 		free(namepath);
-		return -1;
+		return NULL;
 	}
 	namepath = s;
 	strcat(namepath, "/name");
 	data = xs_read(xs, XBT_NULL, namepath, &len);
 	free(namepath);
 	if (!data)
-		return -1;
+		return NULL;
 	if (!len) {
 		free(data);
-		return -1;
+		return NULL;
 	}
 
 	snprintf(logfile, PATH_MAX-1, "%s/guest-%s.log", log_dir, data);
 	free(data);
 	logfile[PATH_MAX-1] = '\0';
 
-	fd = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0644);
-	if (fd == -1)
+	tmp = logfile_new(logfile, 0644);
+
+	if (!tmp)
 		dolog(LOG_ERR, "Failed to open log %s: %d (%s)",
 		      logfile, errno, strerror(errno));
-	if (fd != -1 && log_time_guest) {
-		if (write_with_timestamp(fd, "Logfile Opened\n",
-					 strlen("Logfile Opened\n"),
-					 &log_time_guest_needts) < 0) {
+
+	if (tmp && log_time_guest) {
+		if (write_logfile_with_timestamp(tmp, "Logfile Opened\n",
+						 strlen("Logfile Opened\n"),
+						 &log_time_guest_needts) < 0) {
 			dolog(LOG_ERR, "Failed to log opening timestamp "
-				       "in %s: %d (%s)", logfile, errno,
+				       "in %s: %d (%s)", tmp->basepath, errno,
 				       strerror(errno));
-			close(fd);
-			return -1;
+			logfile_free(tmp);
+			return NULL;
 		}
 	}
-	return fd;
+
+	return tmp;
 }
 
 static void domain_close_tty(struct domain *dom)
@@ -665,8 +669,8 @@ static int domain_create_ring(struct domain *dom)
 		}
 	}
 
-	if (log_guest && (dom->log_fd == -1))
-		dom->log_fd = create_domain_log(dom);
+	if (log_guest && !dom->log)
+		dom->log = create_domain_log(dom);
 
  out:
 	return err;
@@ -724,7 +728,6 @@ static struct domain *create_domain(int domid)
 	dom->master_fd = -1;
 	dom->master_pollfd_idx = -1;
 	dom->slave_fd = -1;
-	dom->log_fd = -1;
 	dom->xce_pollfd_idx = -1;
 
 	dom->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD;
@@ -777,9 +780,9 @@ static void cleanup_domain(struct domain *d)
 {
 	domain_close_tty(d);
 
-	if (d->log_fd != -1) {
-		close(d->log_fd);
-		d->log_fd = -1;
+	if (d->log) {
+		logfile_free(d->log);
+		d->log = NULL;
 	}
 
 	free(d->buffer.data);
@@ -995,9 +998,9 @@ static void handle_log_reload(void)
 	if (log_guest) {
 		struct domain *d;
 		for (d = dom_head; d; d = d->next) {
-			if (d->log_fd != -1)
-				close(d->log_fd);
-			d->log_fd = create_domain_log(d);
+			if (d->log)
+				logfile_free(d->log);
+			d->log = create_domain_log(d);
 		}
 	}
 
