diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -N -r -u ./config/Makefile.in ./config/Makefile.in
--- ./config/Makefile.in	2006-07-21 21:29:24.000000000 +0200
+++ ./config/Makefile.in	2006-07-23 20:38:01.000000000 +0200
@@ -142,7 +142,7 @@
 CDK_SRCS += $(LIB)/autoconf.ml
 
 
-CDK_SRCS+= $(LIB)/fifo.ml $(CDK)/arg2.ml $(CDK)/printf2.ml \
+CDK_SRCS+= $(LIB)/fifo.ml $(CDK)/arg2.ml $(LIB)/syslog.ml $(CDK)/printf2.ml \
   $(CDK)/heap.ml \
   $(CDK)/printexc2.ml $(CDK)/genlex2.ml \
   $(CDK)/filepath.ml $(CDK)/string2.ml \
@@ -172,7 +172,7 @@
 	$(LIB)/bitv.ml \
   $(LIB)/intmap.ml $(LIB)/stringMap.ml \
   $(LIB)/int64ops.ml $(LIB)/options.ml4 \
-  $(LIB)/syslog.ml $(LIB)/levenshtein.ml \
+  $(LIB)/levenshtein.ml \
   $(LIB)/intset.ml \
   $(LIB)/store.ml \
   $(LIB)/indexer.ml $(LIB)/indexer1.ml $(LIB)/indexer2.ml \
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -N -r -u ./src/daemon/common/commonOptions.ml ./src/daemon/common/commonOptions.ml
--- ./src/daemon/common/commonOptions.ml	2006-07-20 13:07:03.000000000 +0200
+++ ./src/daemon/common/commonOptions.ml	2006-07-23 20:38:01.000000000 +0200
@@ -25,6 +25,14 @@
 open Options
 open Unix
 
+let log_prefix = "[cO]"
+
+let lprintf_nl fmt =
+  lprintf_nl2 log_prefix fmt
+
+let lprintf_n fmt =
+  lprintf2 log_prefix fmt
+
 let _s x = _s "CommonOptions" x
 let _b x = _b "CommonOptions" x
 
@@ -1518,6 +1526,12 @@
     also enable logging in a file after startup using the 'log_file' command."
   string_option "mlnet.log"
 
+let log_to_syslog = define_expert_option current_section ["log_to_syslog"]
+   "Post log messages to syslog. This setting is independent of log_file
+and its associated commands, therefore close_log does not stop log to syslog.
+Its therefore possible to log to syslog and log_file at the same time."
+    bool_option false
+
 let gui_log_size =
   define_expert_option current_section ["gui_log_size"]
     "number of lines for GUI console messages" int_option 30
@@ -1802,6 +1816,26 @@
 
 
 let _ =
+  option_hook log_to_syslog (fun _ ->
+    match !Printf2.syslog_oc with
+      None ->
+	if !!log_to_syslog then
+	  begin
+	    Printf2.syslog_oc := (
+              try
+                Some (Syslog.openlog (Filename.basename Sys.argv.(0)))
+              with e -> log_to_syslog =:= false;
+	        lprintf_nl "error while opening syslog %s" (Printexc2.to_string e); None);
+	    lprintf_nl "activated syslog"
+	  end
+    | Some oc ->
+	if not !!log_to_syslog then
+	  begin
+	    lprintf_nl "deactivated syslog";
+	    Syslog.closelog oc;
+	    Printf2.syslog_oc := None
+	  end
+  );
   option_hook loop_delay (fun _ ->
      BasicSocket.loop_delay := (float_of_int !!loop_delay) /. 1000.;
   );
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -N -r -u ./src/networks/donkey/donkeyComplexOptions.ml ./src/networks/donkey/donkeyComplexOptions.ml
--- ./src/networks/donkey/donkeyComplexOptions.ml	2006-07-20 17:30:21.000000000 +0200
+++ ./src/networks/donkey/donkeyComplexOptions.ml	2006-07-23 20:38:01.000000000 +0200
@@ -535,17 +535,13 @@
 let guptime () = !!guptime - !diff_time
   
 let load_sources () =
-  (lprintf "(loading sources ";
-   try 
+  (try 
       let cleaner = DonkeySources.attach_sources_to_file file_sources_section in
       cleaner ();
-      lprintf ".";
       Options.load file_sources_ini;
-      lprintf ".";
       cleaner ();
-      lprintf ".";
       sources_loaded := true;
-      lprintf " completed) ";
+      lprintf "loading sources completed) ";
     with _ -> ())
 
 let check_result r tags =
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -N -r -u ./src/utils/cdk/printf2.ml ./src/utils/cdk/printf2.ml
--- ./src/utils/cdk/printf2.ml	2006-07-15 13:48:21.000000000 +0200
+++ ./src/utils/cdk/printf2.ml	2006-07-23 20:38:01.000000000 +0200
@@ -19,6 +19,9 @@
 
 
 open Autoconf
+open Syslog
+
+let syslog_oc = ref None
 
 external format_int: string -> int -> string = "caml_format_int"
 external format_int32: string -> int32 -> string = "caml_int32_format"
@@ -190,24 +193,24 @@
     Buffer.add_string dest (printer ()); doprn i
   in doprn 0
 
-let lprintf_handler = ref (fun s ->
-      Printf.printf "Message [%s] discarded\n" s;
+let lprintf_handler = ref (fun s time ->
+      Printf.printf "%sMessage [%s] discarded\n" time s;
   )
 
 let lprintf fmt =
-  cprintf (fun s -> try !lprintf_handler s with _ -> ())
+  cprintf (fun s -> try !lprintf_handler "" s with _ -> ())
   (fmt : ('a,unit, unit) format )
 
 let lprintf2 m fmt =
-  cprintf (fun s -> try !lprintf_handler ((log_time ())^m^" "^s) with _ -> ())
+  cprintf (fun s -> try !lprintf_handler (log_time ()) (m^" "^s) with _ -> ())
   (fmt : ('a,unit, unit) format )
 
 let lprintf_nl fmt =
-  cprintf (fun s -> try !lprintf_handler ((log_time ())^s^"\n") with _ -> ())
+  cprintf (fun s -> try !lprintf_handler (log_time ()) (s^"\n") with _ -> ())
   (fmt : ('a,unit, unit) format )
 
 let lprintf_nl2 m fmt =
-  cprintf (fun s -> try !lprintf_handler ((log_time ())^m^" "^s^"\n") with _ -> ())
+  cprintf (fun s -> try !lprintf_handler (log_time ()) (m^" "^s^"\n") with _ -> ())
   (fmt : ('a,unit, unit) format )
 
 let lprint_newline () = lprintf "\n"
@@ -232,16 +235,19 @@
   | _ -> false
 
 let _ =
-  set_lprintf_handler (fun s ->
+  set_lprintf_handler (fun time s ->
+      (match !syslog_oc with
+	None -> ()
+      | Some oc -> Syslog.syslog oc `LOG_INFO s);
       match !lprintf_output with
         Some out when !lprintf_to_channel ->
-          Printf.fprintf out "%s" s; flush out
+          Printf.fprintf out "%s" (time ^ s); flush out
       | _ ->
           if !lprintf_size >= !lprintf_max_size then
             ignore (Fifo.take lprintf_fifo)
           else
             incr lprintf_size;
-          Fifo.put lprintf_fifo s
+          Fifo.put lprintf_fifo (time ^ s)
   )
 
 let detach () =
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -N -r -u ./src/utils/cdk/printf2.mli ./src/utils/cdk/printf2.mli
--- ./src/utils/cdk/printf2.mli	2006-07-14 16:23:37.000000000 +0200
+++ ./src/utils/cdk/printf2.mli	2006-07-23 20:38:01.000000000 +0200
@@ -19,6 +19,8 @@
 
 open Autoconf
 
+val syslog_oc : Syslog.t option ref
+
 val lprintf_original_output : out_channel option ref
 val keep_console_output : unit -> bool
 
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -N -r -u ./src/utils/lib/syslog.ml ./src/utils/lib/syslog.ml
--- ./src/utils/lib/syslog.ml	2006-07-21 21:29:24.000000000 +0200
+++ ./src/utils/lib/syslog.ml	2006-07-23 20:39:59.000000000 +0200
@@ -203,11 +203,10 @@
       if String.length loginfo.tag > 0 then
 	Buffer.add_string msg ": ";
       Buffer.add_string msg str;
-      Buffer.add_char msg '\000';
       let realmsg = ref (Buffer.contents msg) in
 	if String.length !realmsg > 1024 then begin
 	  realmsg := String.sub !realmsg 0 1024;
-	  String.blit "<truncated>\000" 0 !realmsg 1012 12
+	  String.blit "<truncated>" 0 !realmsg 1012 11
 	end;
 	begin try
 	  ignore (Unix.write loginfo.fd !realmsg 0 (String.length !realmsg))
@@ -221,8 +220,10 @@
 		log_console !realmsg
 	end;
 	if List.mem `LOG_PERROR loginfo.flags then begin
-	  ignore (Unix.write Unix.stderr !realmsg 0 (String.length !realmsg));
-	  ignore (Unix.write Unix.stderr "\n" 0 1)
+	  try
+	    ignore (Unix.write Unix.stderr !realmsg 0 (String.length !realmsg));
+	    ignore (Unix.write Unix.stderr "\n" 0 1)
+	  with _ -> ()
 	end
 
 let closelog loginfo =
