I am trying to log Parsing errors to a log file. Here's the snippet of code that is used to write to the log file.
if(!array_key_exists(1,$match))
{
$result = file_put_contents("$mapdir/$log_fname","\n$link",FILE_APPEND | LOCK_EX);
if($result===False) echo "Write failed";
else echo "$result bytes written to $mapdir/$log_fname - ";
echo "Link error: $link\n";
return False;
}
This returns-
104 bytes written to configs/test/log - Link error: FR3.SYD - 10GigabitEthernet5/1 - TRDU PUBLICP|10GE|PIPE NETWORKS|18398|LLNW-00004034 [EQX: NETPROV-981]
Which means that the contents were successfully written but when I open the file written to by vi command I see the same file. No content has been added.
Notes-
- The file I am writing to exists.
- Permissions for all have been set to 777 using chmod -R
- I am also writing to several config files in the same location with this script successfully using file_put_contents.
Then why do you think I am facing this problem now with the log file?