Index: /trunk/PS-IPP-Config/lib/PS/IPP/Config.pm
===================================================================
--- /trunk/PS-IPP-Config/lib/PS/IPP/Config.pm	(revision 32373)
+++ /trunk/PS-IPP-Config/lib/PS/IPP/Config.pm	(revision 32374)
@@ -20,4 +20,5 @@
 use Getopt::Long 2.33 qw( GetOptions :config gnu_getopt pass_through ); # Set pass_through so we don't kill @ARGV
 use IPC::Cmd 0.36 qw( can_run run );
+use POSIX qw( strftime );
 
 use base qw( Exporter Class::Accessor::Fast );
@@ -692,4 +693,6 @@
 }
 
+
+
 # redirect stderr and stdout streams to a file
 sub redirect_output
@@ -722,4 +725,43 @@
 
     return 1;
+}
+
+# redirect stderr and stdout streams to log file. If file already exists rename it and record
+# the name in the new log file.
+sub redirect_to_logfile {
+    my $self = shift;
+    my $name = shift;
+    
+    my $tstring = strftime "%Y%m%dT%H%M", gmtime;
+
+    my $old_name;
+    my $scheme = file_scheme($name);
+    if ($scheme eq 'neb') {
+        my $neb = $self->nebulous;
+        if ($neb->storage_object_exists($name)) {
+            eval {
+                $old_name = "$name.$tstring";
+                $neb->move($name, $old_name);
+            };
+            if ($@) {
+                carp "nebulous move failed for $name";
+                return undef;
+            }
+        }
+    } else {
+        if ($self->file_exists($name)) {
+            my $resolved = $self->file_resolve($name);
+            $old_name = "$resolved.$tstring";
+            if (!rename($resolved, $old_name)) {
+                carp "Failed to rename $resolved $old_name";
+                return undef;
+            }
+        }
+    }
+    my $result = $self->redirect_output($name);
+    if ($result and $old_name) {
+        print "\nPrevious log file moved to $old_name\n";
+    }
+    return $result;
 }
 
Index: /trunk/ippScripts/scripts/chip_imfile.pl
===================================================================
--- /trunk/ippScripts/scripts/chip_imfile.pl	(revision 32373)
+++ /trunk/ippScripts/scripts/chip_imfile.pl	(revision 32374)
@@ -44,6 +44,4 @@
 my ( $exp_id, $chip_id, $class_id, $chip_imfile_id, $uri, $camera, $outroot, $dbname, $run_state, $reduction, $threads, $verbose,
      $no_update, $save_temps, $no_op, $redirect, $magicked, $deburned );
-
-my $zaplog = 0;
 
 GetOptions(
@@ -65,5 +63,4 @@
     'no-op'             => \$no_op,     # Don't do any operations?
     'redirect-output'   => \$redirect,
-    'zaplog'            => \$zaplog,
     'save-temps'        => \$save_temps, # Save temporary files?
     ) or pod2usage( 2 );
@@ -92,15 +89,18 @@
 }
 
-my ($logDest, $traceDest);
+my ($logRule, $traceDest);
 if ($run_state eq 'new') {
-    $logDest = prepare_output("LOG.IMFILE", $outroot, $class_id, $zaplog);
+    $logRule = "LOG.IMFILE";
     $traceDest = prepare_output("TRACE.IMFILE",  $outroot, $class_id, 1);
 } else {
-    $logDest = prepare_output("LOG.IMFILE.UPDATE", $outroot, $class_id, 1);
+    $logRule = "LOG.IMFILE.UPDATE";
     $traceDest = prepare_output("TRACE.IMFILE.UPDATE",  $outroot, $class_id, 1);
 }
 
 if ($redirect) {
-    $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR );
+    my $logDest = $ipprc->filename($logRule, $outroot, $class_id);
+
+    $ipprc->redirect_to_logfile($logDest) or my_die( "Unable to redirect output", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR );
+
     print STDOUT "\n\n";
     print STDOUT "Starting script $0 on $host\n\n";
@@ -451,5 +451,5 @@
     $command .= " -image_id $chip_imfile_id" if defined $chip_imfile_id;
     $command .= " -source_id $source_id" if defined $source_id;
-    $command .= " -tracedest $traceDest -log $logDest";
+    $command .= " -tracedest $traceDest";
     $command .= " -dbname $dbname" if defined $dbname;
 
