{"id":9576,"date":"2026-06-03T06:48:48","date_gmt":"2026-06-03T04:48:48","guid":{"rendered":"https:\/\/mybox.com\/help\/?post_type=manual_kb&#038;p=9576"},"modified":"2026-06-08T09:35:59","modified_gmt":"2026-06-08T07:35:59","slug":"cum-sa-salvati-jurnalele-de-erori-php-intr-un-fisier","status":"publish","type":"manual_kb","link":"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-save-php-error-logs-to-a-file\/","title":{"rendered":"Cum s\u0103 salva\u021bi jurnalele de erori PHP \u00eentr-un fi\u0219ier"},"content":{"rendered":"<div class=\"translation-block translation-block-merged\">\n<p class=\"wp-block-paragraph\">When troubleshooting a website or PHP application, it can be helpful to save PHP errors to a log file instead of displaying them directly on the page. This allows you to review errors later without exposing technical details to visitors.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can enable PHP error logging by adding a few directives to the website&#8217;s <code>.htaccess<\/code> file.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_86 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-save-php-error-logs-to-a-file\/#Step_1_Locate_the_htaccess_File\" >Step 1: Locate the .htaccess File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-save-php-error-logs-to-a-file\/#Step_2_Enable_PHP_Error_Logging\" >Step 2: Enable PHP Error Logging<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-save-php-error-logs-to-a-file\/#What_Do_These_Directives_Do\" >What Do These Directives Do?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-save-php-error-logs-to-a-file\/#Step_3_Generate_an_Error\" >Step 3: Generate an Error<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-save-php-error-logs-to-a-file\/#Step_4_Review_the_Log_File\" >Step 4: Review the Log File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-save-php-error-logs-to-a-file\/#Important_Security_Recommendation\" >Important Security Recommendation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-save-php-error-logs-to-a-file\/#Summary\" >Summary<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_1_Locate_the_htaccess_File\"><\/span>Step 1: Locate the <code>.htaccess<\/code> File<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<\/div>\n\n<div id=\"mybox-767937706\" class=\"mybox-content mybox-entity-placement\"><div class=\"early-access-banner-inpost\">\r\n  <div class=\"banner-left-inpost\">\r\n    <div class=\"icon-box-inpost\">\r\n      <img decoding=\"async\" src=\"https:\/\/mybox.com\/help\/wp-content\/uploads\/2026\/02\/square-info-icon.svg\" alt=\"Info\">\r\n    <\/div>\r\n    <div class=\"text-box-inpost\">\r\n      <span class=\"label-inpost\"><span class=\"translation-block translation-block-banner-text\">Acces timpuriu<\/span><\/span>\r\n      <h4><span class=\"translation-block translation-block-banner-text\">Mai ave\u021bi nevoie de ajutor?<\/span><\/h4>\r\n      <p><span class=\"translation-block translation-block-banner-text\">Contacta\u021bi echipa noastr\u0103 de servicii pentru clien\u021bi.<\/span><\/p>\r\n    <\/div>\r\n  <\/div>\r\n\r\n  <div class=\"banner-right-inpost\">\r\n    <a href=\"https:\/\/panel.mybox.com\/helpdesk2\/v\/list\/\" class=\"banner-button-inpost\"><span class=\"translation-block translation-block-banner-text\">Trimite mesaj<\/span><\/a>\r\n  <\/div>\r\n<\/div><\/div>\n\n<div class=\"translation-block translation-block-merged\"><p class=\"wp-block-paragraph\">Connect to your hosting account using FTP and navigate to your website&#8217;s main directory, typically:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public_html<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Locate the file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.htaccess<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> The filename begins with a dot (<code>.<\/code>). Some FTP clients hide files that start with a dot by default.<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_2_Enable_PHP_Error_Logging\"><\/span>Step 2: Enable PHP Error Logging<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Add the following lines to the <code>.htaccess<\/code> file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php_value error_reporting 1<br>php_value log_errors 1<br>php_value error_log \/home\/client.mybox.com\/&lt;LOGIN&gt;\/&lt;DIRECTORY&gt;\/PHP_errors.log<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>&lt;LOGIN&gt;<\/code> with your hosting account login<\/li>\n\n\n\n<li><code>&lt;DIRECTORY&gt;<\/code> with the directory where you want the log file to be created<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php_value error_reporting 1<br>php_value log_errors 1<br>php_value error_log \/home\/client.mybox.com\/john\/public_html\/PHP_errors.log<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_Do_These_Directives_Do\"><\/span>What Do These Directives Do?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Directive<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>error_reporting<\/code><\/td><td>Enables PHP error reporting<\/td><\/tr><tr><td><code>log_errors<\/code><\/td><td>Tells PHP to save errors to a file<\/td><\/tr><tr><td><code>error_log<\/code><\/td><td>Specifies the location of the log file<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_3_Generate_an_Error\"><\/span>Step 3: Generate an Error<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After saving the changes, reproduce the issue on your website.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">PHP will automatically write error messages to the specified log file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_4_Review_the_Log_File\"><\/span>Step 4: Review the Log File<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Open the file specified in the <code>error_log<\/code> directive:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PHP_errors.log<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You will find entries similar to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;06-Jun-2026 12:34:56] PHP Fatal error: Uncaught Error: Call to undefined function...<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">These messages can help identify:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>PHP syntax errors<\/li>\n\n\n\n<li>Fatal errors<\/li>\n\n\n\n<li>Warnings<\/li>\n\n\n\n<li>Notices<\/li>\n\n\n\n<li>Missing files or functions<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Important_Security_Recommendation\"><\/span>Important Security Recommendation<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For production websites, it is generally recommended to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Log errors to a file<\/li>\n\n\n\n<li>Avoid displaying errors directly to visitors<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Displaying PHP errors publicly may reveal sensitive information about your application or server configuration.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Summary\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To save PHP errors to a file, add the appropriate <code>php_value<\/code> directives to your website&#8217;s <code>.htaccess<\/code> file and specify the location of the log file. Once enabled, PHP will record errors in the designated file, making it easier to diagnose and resolve application issues without exposing error messages to website visitors.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"template":"","format":"standard","manualknowledgebasecat":[39],"manual_kb_tag":[718,1601,4213,4265,5179,5180,5181,5182,5183,5184],"class_list":["post-9576","manual_kb","type-manual_kb","status-publish","format-standard","hentry","manualknowledgebasecat-php-operations","manual_kb_tag-htaccess-file","manual_kb_tag-website-troubleshooting","manual_kb_tag-error-reporting","manual_kb_tag-php-error-log","manual_kb_tag-php-error-logging","manual_kb_tag-error-log-file","manual_kb_tag-enable-error-logging","manual_kb_tag-log-errors","manual_kb_tag-error-log-location","manual_kb_tag-debugging-php"],"_links":{"self":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/9576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":2,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/9576\/revisions"}],"predecessor-version":[{"id":9577,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/9576\/revisions\/9577"}],"wp:attachment":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/media?parent=9576"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manualknowledgebasecat?post=9576"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb_tag?post=9576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}