php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #77667 Duplicate error log entries and configurable date format
Submitted: 2019-02-25 20:17 UTC Modified: 2019-04-13 17:44 UTC
From: valentiny510 at gmail dot com Assigned:
Status: Open Package: *General Issues
PHP Version: 7.2.15 OS: Irrelevant
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-02-25 20:17 UTC] valentiny510 at gmail dot com
Description:
------------
When you try to inlude a non existent file, in the log appear two similar entries.

[date] PHP Warning:  require(non_existent_file): failed to open stream: No such file or directory in .../index.php on line 5
[date] PHP Fatal error:  require(): Failed opening required 'non_existent_file' (include_path='...') in .../index.php on line 5

They are not exactly the same, so technically is a not a duplicate, but,
they point to the same error, is kinda redundant IMHO, and also a bit confusing
for the different error types, is just a Warning or Fatal error ?
Is clear that one error is because the 'stream' to be parsed is empty or non existent and the other is an error because of the language construct 'require'
does not have a valid file to include... Is not a bug, of course, that's why I am asking as a feature request to remove one of them, and let just one simpler entry, Ex: 'PHP Warning: file "xxx" not found, in file .../index.php, line 5'
Let only the Warning for instance since the included file may not be so important for the entire framework execution to be Fatal...

And if possible, PLEASE let us REMOVE THE TIMEZONE from the date of the logs...
preferably have a 'log_format = %H.%i.%s' in the php.ini settings
[..... Europe/IrrelevantCity]
(Of course I know that we can have a custom error log system implemented, but...)
Also would be nice (for security reasons) to have the option to NOT LOG the full paths, and log only the path/files.php relative to the root

 Thank you



Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-02-28 20:54 UTC] beberlei@php.net
These are not duplicate errors, but as you mentioned the warning leads to the follow up fatal error. The reason why it stops here is you are using require(), whose stated feature contrary to include() is exactly stopping the execution if the file cannot be loaded/executed. So everything here is working as expected. With include you get a second warning and execution continues.

Since include/require both allow stream wrappers, it is important to have both error messages, because the different systems need to be able to report the problems they have.
 [2019-02-28 21:15 UTC] beberlei@php.net
Pull Request for your date format feature request: https://github.com/php/php-src/pull/3899
 [2019-03-01 14:52 UTC] beberlei@php.net
The following pull request has been associated:

Patch Name: Add new core INI setting "error_date_format" to customize date format
On GitHub:  https://github.com/php/php-src/pull/3899
Patch:      https://github.com/php/php-src/pull/3899.patch
 [2019-03-01 14:53 UTC] beberlei@php.net
-Summary: Duplicate error log entries +Summary: Duplicate error log entries and date format not configurable
 [2019-04-13 17:40 UTC] valentiny510 at gmail dot com
That is awesome ! Thank you

The logs (generally) are meant for the developers, and they should already know on that Continent/City is located the server (or servers), is kinda silly to have the logs full of useless information that only make the logs larger in size.
For instance the largest identifiers are 30 bytes long (America/Argentina/Buenos_Aires)...
a simple log with 1.000.000 lines is increased by 28+ MB only with that useless repetition, I know it doesn't seems too much and some can argue that the rotate
logs will use compression, etc, but...

And if we are talking about logs... I whould like to see another feature implemented...
(again, I know we can implement custom error logs)
and is, having the ability to log in a specified file format, json, csv, etc...
similar to error_log(sprintf('["%s","%s",%d,...]%s', date, ip, port, ..., PHP_EOL))
Using json/array format is easier to search within the logs specific dates, ips, etc,
with a simple isset(line[ x ]), in_array(ip), array_search(date), whatever...

and as bonus, for error_log, whould be nice to autocreate the path/file.log if does not exists.

Thank you, and thank you again Beberlei for the pull request
 [2019-04-13 17:44 UTC] valentiny510 at gmail dot com
-Summary: Duplicate error log entries and date format not configurable +Summary: Duplicate error log entries and configurable date format
 [2019-04-13 17:44 UTC] valentiny510 at gmail dot com
-Summary: Duplicate error log entries and date format not configurable 
+Summary: Duplicate error log entries and configurable date format
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Apr 22 02:01:25 2019 UTC