Index: trunk/ippMonitor/czartool/czarpoll.pl
===================================================================
--- trunk/ippMonitor/czartool/czarpoll.pl	(revision 42931)
+++ trunk/ippMonitor/czartool/czarpoll.pl	(revision 42972)
@@ -26,4 +26,12 @@
 use czartool::DayMetrics;
 use czartool::MetricsIndex;
+
+# --- Logging setup ---
+use IO::Handle;
+my $log_file = "/tmp/czarpoll.log";
+open(my $LOG, '>>', $log_file) or die "Cannot open log file $log_file: $!";
+$LOG->autoflush(1);
+select($LOG);  # Redirect all print statements to the log file
+open(STDERR, '>&', $LOG) or die "Cannot redirect STDERR to log file: $!";
 
 my $period = 60;
@@ -149,7 +157,9 @@
         my @labels = @{$pantasks->getLabels($server,'gpc1')};
 	push (@allLabels, @labels);
+        #print "[$server gpc1] labels: ", join(", ", @labels), "\n";
 
         my @labels2 = @{$pantasks->getLabels($server,'gpc2')};
 	push (@allLabels2, @labels2);
+        #print "[$server gpc2] labels: ", join(", ", @labels2), "\n";
     }
     #The way gpc2 pantasks are set up is different from gpc1. Therefore, the same label can appear in both stdscience and distribution. 
@@ -309,4 +319,15 @@
     while (1) {
 
+        # --- Truncate log file at start of each iteration ---
+        close($LOG);
+        open($LOG, '>', $log_file) or die "Cannot reopen log file $log_file: $!";
+        $LOG->autoflush(1);
+        select($LOG); # Redirect STDERR (error messages) to the same log file
+        open(STDERR, '>&', $LOG) or die "Cannot redirect STDERR to log file: $!";
+
+        print "\n======================== CZARPOLL ITERATION START ========================\n";
+        print scalar(localtime) . "\n";
+        print "==========================================================================\n";
+
         my $iterationStartTime = time();
  
@@ -447,4 +468,6 @@
 
         print "--------------------------------------------------------------------------\n";
+        print "Iteration complete at " . scalar(localtime) . "\n";
+        print "==========================================================================\n";
         if ($iterationTime < $period) {
             print "* Going to sleep\n";
