{"id":268,"date":"2007-06-21T12:35:11","date_gmt":"2007-06-21T02:35:11","guid":{"rendered":"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/"},"modified":"2007-06-26T18:39:57","modified_gmt":"2007-06-26T08:39:57","slug":"error-logging-in-php","status":"publish","type":"post","link":"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/","title":{"rendered":"Error logging in PHP"},"content":{"rendered":"<p>One of the most important tasks of any developer is to know what errors occur in his application, because it is impossible to fix them if you don't know if they exist in the first place.   Although you may think that your application is perfect and bugs free, you can never be 100% sure because users might not operate the application in the way you expect them to.    And this is when error logging come in, where you record any errors that users encounter in a log file which can be used to improve your application.    In PHP, you can control how errors are handled and reported.  The following is an example of how errors may be logged:<\/p>\n<p><code><br \/>\n\/\/ Error Reporting settings<br \/>\nini_set('error_reporting', E_ALL ^ E_NOTICE); \/\/ log all errors except <a href=\"http:\/\/au3.php.net\/manual\/en\/ref.errorfunc.php#errorfunc.constants.errorlevels.e-notice\">notices<\/a><br \/>\nini_set('log_errors', true); \/\/ enable error logging<br \/>\nini_set('html_errors', false); \/\/ disable html errors<br \/>\nini_set('error_log', '\/home\/directory\/to\/your\/error_log.txt'); \/\/ save all the errors to a log file<br \/>\nini_set('display_errors', true); \/\/ do not display errors on screen<br \/>\n<\/code><\/p>\n<p><strong>Related articles:<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/au2.php.net\/errorfunc\">Error Handling and Logging Functions<\/a><\/li>\n<li><a href=\"http:\/\/www.julian-bez.de\/blog\/2006\/02\/19\/how-to-set-up-error-logging-with-php\/\">How to set up error logging with PHP<\/a><\/li>\n<li><a href=\"http:\/\/www.devshed.com\/c\/a\/PHP\/Logging-With-PHP\/\">Logging With PHP<\/a><\/li>\n<\/ul>\n<p>[tags]php, programming, error logging, development[\/tags]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the most important tasks of any developer is to know what errors occur<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,8,11],"tags":[],"class_list":["post-268","post","type-post","status-publish","format-standard","hentry","category-php","category-snippets","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Error logging in PHP | Tech Leadership Advice &amp; Resources<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Error logging in PHP | Tech Leadership Advice &amp; Resources\" \/>\n<meta property=\"og:description\" content=\"One of the most important tasks of any developer is to know what errors occur\" \/>\n<meta property=\"og:url\" content=\"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/\" \/>\n<meta property=\"og:site_name\" content=\"Tech Leadership Advice &amp; Resources\" \/>\n<meta property=\"article:published_time\" content=\"2007-06-21T02:35:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2007-06-26T08:39:57+00:00\" \/>\n<meta name=\"author\" content=\"Isabel Nyo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Isabel Nyo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/\"},\"author\":{\"name\":\"Isabel Nyo\",\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab\"},\"headline\":\"Error logging in PHP\",\"datePublished\":\"2007-06-21T02:35:11+00:00\",\"dateModified\":\"2007-06-26T08:39:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/\"},\"wordCount\":147,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab\"},\"articleSection\":[\"PHP\",\"Snippets\",\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/\",\"url\":\"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/\",\"name\":\"Error logging in PHP | Tech Leadership Advice &amp; Resources\",\"isPartOf\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#website\"},\"datePublished\":\"2007-06-21T02:35:11+00:00\",\"dateModified\":\"2007-06-26T08:39:57+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/eisabainyo.net\/weblog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Error logging in PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#website\",\"url\":\"https:\/\/eisabainyo.net\/weblog\/\",\"name\":\"Career Resources for Professionals in Tech\",\"description\":\"Books, worksheets, templates, frameworks and other useful resources for Chief Technology Officers (CTOs), VPs of Engineering &amp; Technology Directors\",\"publisher\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/eisabainyo.net\/weblog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab\",\"name\":\"Isabel Nyo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3d4b1a4e0f425adb39b242b0d62c5fac07c82f8314a24631f1d16f47bdf006d8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3d4b1a4e0f425adb39b242b0d62c5fac07c82f8314a24631f1d16f47bdf006d8?s=96&d=mm&r=g\",\"caption\":\"Isabel Nyo\"},\"logo\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/image\/\"},\"description\":\"My interests: Web Development, Web Design, Web Applications, Web 2.0, AJAX, Search Engine Optimisation, Latest Technologies and more..\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Error logging in PHP | Tech Leadership Advice &amp; Resources","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/","og_locale":"en_US","og_type":"article","og_title":"Error logging in PHP | Tech Leadership Advice &amp; Resources","og_description":"One of the most important tasks of any developer is to know what errors occur","og_url":"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/","og_site_name":"Tech Leadership Advice &amp; Resources","article_published_time":"2007-06-21T02:35:11+00:00","article_modified_time":"2007-06-26T08:39:57+00:00","author":"Isabel Nyo","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Isabel Nyo","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/#article","isPartOf":{"@id":"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/"},"author":{"name":"Isabel Nyo","@id":"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab"},"headline":"Error logging in PHP","datePublished":"2007-06-21T02:35:11+00:00","dateModified":"2007-06-26T08:39:57+00:00","mainEntityOfPage":{"@id":"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/"},"wordCount":147,"commentCount":0,"publisher":{"@id":"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab"},"articleSection":["PHP","Snippets","Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/","url":"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/","name":"Error logging in PHP | Tech Leadership Advice &amp; Resources","isPartOf":{"@id":"https:\/\/eisabainyo.net\/weblog\/#website"},"datePublished":"2007-06-21T02:35:11+00:00","dateModified":"2007-06-26T08:39:57+00:00","breadcrumb":{"@id":"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/eisabainyo.net\/weblog\/2007\/06\/21\/error-logging-in-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/eisabainyo.net\/weblog\/"},{"@type":"ListItem","position":2,"name":"Error logging in PHP"}]},{"@type":"WebSite","@id":"https:\/\/eisabainyo.net\/weblog\/#website","url":"https:\/\/eisabainyo.net\/weblog\/","name":"Career Resources for Professionals in Tech","description":"Books, worksheets, templates, frameworks and other useful resources for Chief Technology Officers (CTOs), VPs of Engineering &amp; Technology Directors","publisher":{"@id":"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/eisabainyo.net\/weblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab","name":"Isabel Nyo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3d4b1a4e0f425adb39b242b0d62c5fac07c82f8314a24631f1d16f47bdf006d8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3d4b1a4e0f425adb39b242b0d62c5fac07c82f8314a24631f1d16f47bdf006d8?s=96&d=mm&r=g","caption":"Isabel Nyo"},"logo":{"@id":"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/image\/"},"description":"My interests: Web Development, Web Design, Web Applications, Web 2.0, AJAX, Search Engine Optimisation, Latest Technologies and more.."}]}},"_links":{"self":[{"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/posts\/268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/comments?post=268"}],"version-history":[{"count":0,"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/posts\/268\/revisions"}],"wp:attachment":[{"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/media?parent=268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/categories?post=268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/tags?post=268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}