We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,737 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

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

2
Contributors
5
Replies
6 Hours
Discussion Span
6 Months Ago
Last Updated
6
Views
Question
Answered
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
Moderator
9,265 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,456
Skill Endorsements: 86

how is xdebug?

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
Moderator
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
Moderator
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

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0817 seconds using 2.79MB