简体   繁体   中英

PHP 7.3 not creating/writing to error log file

I have just upgraded to PHP 7.3 (using XAMPP) and for some reason it seems it is not writing errors to the specified log file.

I am getting deprecated errors on page output, but they don't seem to be showing up in any log file - which is more ideal since the errors aren't always visible in the page display, they get hidden in the code if they are generated between attribute values for example.

In my php.ini I have:

error_reporting = E_ALL
display_errors=On
display_startup_errors=On
log_errors=On
log_errors_max_len = 2048
ignore_repeated_errors=Off
ignore_repeated_source=Off
report_memleaks=On
report_memleaks=On
html_errors=On
error_log="C:\xampp\php\logs\php_error_log"

Edit: I just noticed today the file was created recently and it had other errors in there (ones generated from issues in php.ini itself such as deprecated settings about track_errors ), but still not getting anything logged about issues caused by pages themselves.

Edit 2: I have created a separate script to generate errors on purpose and they seem t be logging fine, so I am unsure how these other ones are not logging.

Why am I not getting errors logged from pages?

You need to create the logs folder on make sure your XAMPP is installed on C:\\

C:\\xampp\\php\\

Then restart your Apache in XAMPP and try to create an fatal error by using

trigger_error("Some info",E_USER_ERROR);

Please try this

   <?php
    // Send error message to the server log if error connecting to the database
    if (!mysqli_connect("localhost","bad_user","bad_password","my_db")) {
        error_log("Failed to connect to database!", 0);
    }
    
    // Send email to administrator if we run out of FOO
    if (!($foo = allocate_new_foo())) {
        error_log("Oh no! We are out of FOOs!", 1, "admin@example.com");
    }
    ?>

Definition and Usage

The error_log() function sends an error message to a log, to a file, or to a mail account.

Syntax

error_log(message,type,destination,headers);

**> Parameter Description message Required. Specifies the error message to

log type Optional. Specifies where the error message should go.

Possible values: 0 - Default. Message is sent to PHP's system logger,

using the OS' system logging mechanism or a file, depending on what

the error_log configuration is set to in php.ini 1 - Message is sent

by email to the address in the destination parameter 2 - No longer in

use (only available in PHP 3) 3 - Message is appended to the file

specified in destination 4 - Message is sent directly to the SAPI

logging handler destination Optional. Specifies the destination of the

error message. This value depends on the value of the type parameter

headers Optional. Only used if the type parameter is set to 1.

Specifies additional headers, like From, Cc, and Bcc. Multiple headers

should be separated with a CRLF (\\r\\n) Technical Details Return

Value: TRUE on success, or FALSE on failure PHP Version: 4.0+ PHP

Changelog: PHP 5.2.7: The value of 4 was added to the type parameter**

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM