--- a/README
+++ b/README
@@ -36,6 +36,19 @@ truncated to free up disk space in case
 the default is now to buffer additional data in ram until there is
 disk space available again.
 
+Logging output of a multi-instance program
+==========================================
+
+If the program that produces output has more than one instance logging should
+be done via a fifo, not a pipe, otherwise records will be lost during a reload.
+For example in the case of Apache:
+    CustomLog /some/path/fifo-name
+
+where fifo-name is created with mkfifo. Then start flog with
+    flog -F /some/path/fifo-name output-file
+
+BEFORE launching the daemon. With the -F option flog will run forever, even if
+the daemon terminates. If you want to stop it use kill pid-of-flog.
 
 FEATURES
 ========
--- a/flog.c
+++ b/flog.c
@@ -54,8 +54,8 @@ int dotime (char* prepend_to);
 
 int main(int argc, char** argv)
 {
-  char *eol, *pos;
-  int done = 0;
+  char *eol, *pos, *fifo_name;
+  int done = 0, fifo = 0, fifo_fd = 0;
   int opt = 0;
   int totalwn = 0;
   int disk_is_full = 0;
@@ -88,6 +88,13 @@ int main(int argc, char** argv)
 	conf.max_len = atoi (argv[opt]);
       }
     }
+    else if (!strcmp(argv[opt], "-F")) {
+      opt++;
+      if (opt < argc) {
+	fifo = 1;
+	fifo_name = argv[opt];
+      }
+    }
     else if (!strcmp(argv[opt], "-z")) {
       conf.zap_if_disk_full = 1;
     }
@@ -102,6 +109,7 @@ int main(int argc, char** argv)
 	"	-t	     prepend each line with \"YYYYMMDD;HH:MM:SS: \"\n"
 	"	-T <format>  prepend each line with specified strftime(3) format\n"
 	"	-l <number>  log file length limit (force truncation)\n"
+	"	-F <fifo>    fifo name\n"
 	"	-p <pidfile> pid file\n"
 	"	-z           zap (truncate) log if disk gets full (default: grow buffer)\n",
 	argv[0]);
@@ -119,6 +127,13 @@ int main(int argc, char** argv)
     }
   }
 
+  if (fifo) {
+    if ((fifo_fd = open(fifo_name, O_RDONLY)) < 0) {
+      fprintf(stderr, "Could not open fifo: %s", fifo_name);
+      exit(1);
+    }
+  }
+
   out.name = argv[opt];
   openfile (&out);
 
@@ -137,14 +152,19 @@ int main(int argc, char** argv)
 
     if (buf.used >= buf.size) growbuf (buf.size*2);
 
-    size = read (0, buf.data+buf.used, buf.size-buf.used);
-    if (size > 0) {
+    /* if fifo is not used fifo_fd is zero so reading is done from the pipe */
+    size = read(fifo_fd, buf.data + buf.used, buf.size - buf.used);
+    if (size > 0)
       buf.used += size;
-    }
-    else if (size == 0) {
+    else if (fifo) {
+      close(fifo_fd);
+      if ((fifo_fd = open(fifo_name, O_RDONLY)) < 0) {
+	fprintf(stderr, "Could not re-open fifo: %s", fifo_name);
+	exit(1);
+      }
+      continue;
+    } else
       done = 1;
-    }
-    else { }
 
     for (;;) {
 
