Error Handling (Log) Execution
Am running a script that checks every line in a foreach loop. I would like help in how to tackle this each execution needs to be written to a log file which will show how log it went to process the each line at a time and if there is an error it will break the loop and display the log file.
I was thinking of a try catch or is there a class I can try thanks
tapuwa2002
Junior Poster in Training
56 posts since Dec 2008
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0
You can write the log to file (personally I like log4php), but you could also keep it in memory and output it only if there is a problem. Depends on whether or not you want to keep the log files for a longer period.
pritaeas
Posting Prodigy
9,265 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,456
Skill Endorsements: 86
tapuwa2002
Junior Poster in Training
56 posts since Dec 2008
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0
That's a debugger, it is excellent.
pritaeas
Posting Prodigy
9,265 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,456
Skill Endorsements: 86
I would like to use that to record my loop and write to a file. Did something really simple. Any tips
<?php
$names=array('','John','Scott');
foreach($names as $person){
if($person==""){
xdebug_break();
}
}
?>
tapuwa2002
Junior Poster in Training
56 posts since Dec 2008
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0
Unless you want to trace log with XDebug I think you're on the wrong track. It is a debugger, not a logger. You can write to file with PHP if that's what you want, see fwrite.
pritaeas
Posting Prodigy
9,265 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,456
Skill Endorsements: 86
Question Answered as of 6 Months Ago by
pritaeas