title: How to create a log file in PHP
body: <p>I have 2 functions to parse each one a file Excel their sizes are 673K and 131K. They have the same code just their names.
  One function it read the data from file Excel and the other function it return:</p>
  
  <pre><code>Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (Tried to allow 72 bytes)
  </code></pre>
  
  <p>I have others files Excel their sizes more bigger than this ones and their parsing functions works well.</p>
  
  <p>I want to create a logfile to register every action they do inside the system but I have no idea how to do it. On the other hand I found this solution in Stackoverflow for @Lawrence Cherone:
  <a href="https://stackoverflow.com/questions/19898688/how-to-create-a-logfile-in-php">enter link description here</a></p>
  
  <p>But the problem is the first time I will do a <code>logfile</code>, I don't know how I create it ? I create a new file and I put it in my project ? How I excute it and how I can see the reason of the error in my function ? Or I put this file in the function when I have the error like the solution proposed by @Lawrence Cherone ?
  This solution it seems worked fine and the problem is resolved. 
  This following is my small code of my function, can you guide me how I create this logfile to debug it:</p>
  
  <pre><code>public function parseEquipment($filePath = null) {
          set_time_limit(0);
          $listEquipement = [];       
          $count = 0;
          $chunkSize = 1024;
          $objReader = PHPExcel_IOFactory::createReader(PHPExcel_IOFactory::identify($filePath));
          $spreadsheetInfo = $objReader-&gt;listWorksheetInfo($filePath);
          $chunkFilter = new \Floose\Parse\ChunkReadFilter();
          $objReader-&gt;setReadFilter($chunkFilter);
          $objReader-&gt;setReadDataOnly(true);
          $chunkFilter-&gt;setRows(0, 1);
          $objPHPExcel = $objReader-&gt;load($filePath);
          $totalRows = $spreadsheetInfo[0]['totalRows'];
          for ($startRow = 1; $startRow &lt;= $totalRows; $startRow += $chunkSize) {
              $chunkFilter-&gt;setRows($startRow, $chunkSize);
              $objPHPExcel = $objReader-&gt;load($filePath);
              $sheetData = $objPHPExcel-&gt;getActiveSheet()-&gt;toArray(null, null, true, false);
              $startIndex = ($startRow == 1) ? $startRow : $startRow - 1;
  
              if (!empty($sheetData) &amp;&amp; $startRow &lt; $totalRows) {             
                  $dataToAnalyse = array_slice($sheetData, $startIndex, $chunkSize);
                  //echo 'test1'; 
                  if($dataToAnalyse[1][0]==NULL){
                      //echo 'test2';
                      break;
                  }
  
                  //echo 'test3';
                  //var_dump($sheetData);
                  for ($i = 0; $i &lt; $chunkSize; $i++) {
                      if ($dataToAnalyse[$i]['0'] != NULL) {
                          //echo 'OK';
                          $listEquipement[] = new Article($dataToAnalyse[$i]['3'], $dataToAnalyse[$i]['4'], $dataToAnalyse[$i]['2']);
                      //   echo 'test4';                      
                          $count++;
                          }
                  }
              }
              $objPHPExcel-&gt;disconnectWorksheets();
              unset($objPHPExcel, $sheetData);
          }   
  
          //var_dump(array_slice($sheetData, $startIndex, $chunkSize););
          return $listEquipement; 
      }
  </code></pre>