Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #18403 > unrolled thread

log_errors = Off not work

Started byalex <1j9448a02@lnx159sneakemail.com.invalid>
First post2020-11-18 09:36 +0100
Last post2020-11-19 19:22 +0100
Articles 9 — 4 participants

Back to article view | Back to comp.lang.php


Contents

  log_errors = Off not work alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-11-18 09:36 +0100
    Re: log_errors = Off not work "J.O. Aho" <user@example.net> - 2020-11-18 14:12 +0100
      Re: log_errors = Off not work alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-11-18 16:39 +0100
        Re: log_errors = Off not work "J.O. Aho" <user@example.net> - 2020-11-18 17:09 +0100
          Re: log_errors = Off not work alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-11-18 17:25 +0100
            Re: log_errors = Off not work Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2020-11-18 17:39 +0000
              Re: log_errors = Off not work alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-11-19 16:27 +0100
    Re: log_errors = Off not work Arno Welzel <usenet@arnowelzel.de> - 2020-11-19 15:42 +0100
      Re: log_errors = Off not work alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-11-19 19:22 +0100

#18403 — log_errors = Off not work

Fromalex <1j9448a02@lnx159sneakemail.com.invalid>
Date2020-11-18 09:36 +0100
Subjectlog_errors = Off not work
Message-ID<rp2mf7$14ir$1@gioia.aioe.org>
$ grep 'log_errors =' /etc/php/7.4/cli/php.ini
log_errors = Off

$ date && php -r "error_log('abc');" && ls -l /var/log/error.log
mer 18 nov 2020, 09:25:58, CET
-rw-rw-r-- 1 xxx yyy 25931 nov 18 09:25 /var/log/error.log

As you can see log_errors is Off, but it seems that the log file is 
written: just compare the current date with the file date.

Why?

[toc] | [next] | [standalone]


#18404

From"J.O. Aho" <user@example.net>
Date2020-11-18 14:12 +0100
Message-ID<i1kkt8Fk9stU1@mid.individual.net>
In reply to#18403
On 18/11/2020 09.36, alex wrote:
> $ grep 'log_errors =' /etc/php/7.4/cli/php.ini
> log_errors = Off
> 
> $ date && php -r "error_log('abc');" && ls -l /var/log/error.log
> mer 18 nov 2020, 09:25:58, CET
> -rw-rw-r-- 1 xxx yyy 25931 nov 18 09:25 /var/log/error.log
> 
> As you can see log_errors is Off, but it seems that the log file is 
> written: just compare the current date with the file date.
> 
> Why?

Did you do a tail /var/log/error.log to see that it was your message 
that was written there and not something else that just happen to have 
the same minute for it's log write?

Are you sure your php cli is version 7.4?

did you try to just comment it out by placing ; as the first character 
of the line? Sometimes non-visible characters may cause problems.
(default value is Off)

did you uncomment error_log = syslog or set a custom file?

-- 

  //Aho

[toc] | [prev] | [next] | [standalone]


#18405

Fromalex <1j9448a02@lnx159sneakemail.com.invalid>
Date2020-11-18 16:39 +0100
Message-ID<rp3f76$1kek$1@gioia.aioe.org>
In reply to#18404
Il 18/11/20 14:12, J.O. Aho ha scritto:
> On 18/11/2020 09.36, alex wrote:
>> $ grep 'log_errors =' /etc/php/7.4/cli/php.ini
>> log_errors = Off
>>
>> $ date && php -r "error_log('abc');" && ls -l /var/log/error.log
>> mer 18 nov 2020, 09:25:58, CET
>> -rw-rw-r-- 1 xxx yyy 25931 nov 18 09:25 /var/log/error.log
>>
>> As you can see log_errors is Off, but it seems that the log file is 
>> written: just compare the current date with the file date.
>>
>> Why?
> 
> Did you do a tail /var/log/error.log to see that it was your message 
> that was written there and not something else that just happen to have 
> the same minute for it's log write?
> 
> Are you sure your php cli is version 7.4?
> 
> did you try to just comment it out by placing ; as the first character 
> of the line? Sometimes non-visible characters may cause problems.
> (default value is Off)
> 
> did you uncomment error_log = syslog or set a custom file?
> 

+ php -v
PHP 7.4.3 (cli) (built: Oct  6 2020 15:47:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
     with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
     with Xdebug v2.9.2, Copyright (c) 2002-2020, by Derick Rethans

+ grep 'log_errors =' /etc/php/7.4/cli/php.ini
;log_errors = On

+ grep 'error_log =' /etc/php/7.4/cli/php.ini
;error_log = php_errors.log
;error_log = syslog
error_log = /var/log/error.log

+ php -r 'error_log('\''abc'\'');'

+ tail -n 1 /var/log/error.log
[18-Nov-2020 16:27:59 Europe/Berlin] abc

+ sleep 3

+ php -r 'error_log('\''abc'\'');'

+ tail -n 1 /var/log/error.log
[18-Nov-2020 16:28:02 Europe/Berlin] abc

As you can see the file is written: 16:27:59 < 16:28:02
But why?

[toc] | [prev] | [next] | [standalone]


#18406

From"J.O. Aho" <user@example.net>
Date2020-11-18 17:09 +0100
Message-ID<i1kv9bFm9upU1@mid.individual.net>
In reply to#18405
On 18/11/2020 16.39, alex wrote:
> Il 18/11/20 14:12, J.O. Aho ha scritto:
>> On 18/11/2020 09.36, alex wrote:
>>> $ grep 'log_errors =' /etc/php/7.4/cli/php.ini
>>> log_errors = Off
>>>
>>> $ date && php -r "error_log('abc');" && ls -l /var/log/error.log
>>> mer 18 nov 2020, 09:25:58, CET
>>> -rw-rw-r-- 1 xxx yyy 25931 nov 18 09:25 /var/log/error.log
>>>
>>> As you can see log_errors is Off, but it seems that the log file is 
>>> written: just compare the current date with the file date.
>>>
>>> Why?
>>
>> Did you do a tail /var/log/error.log to see that it was your message 
>> that was written there and not something else that just happen to have 
>> the same minute for it's log write?
>>
>> Are you sure your php cli is version 7.4?
>>
>> did you try to just comment it out by placing ; as the first character 
>> of the line? Sometimes non-visible characters may cause problems.
>> (default value is Off)
>>
>> did you uncomment error_log = syslog or set a custom file?
>>
> 
> + php -v
> PHP 7.4.3 (cli) (built: Oct  6 2020 15:47:56) ( NTS )
> Copyright (c) The PHP Group
> Zend Engine v3.4.0, Copyright (c) Zend Technologies
>      with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
>      with Xdebug v2.9.2, Copyright (c) 2002-2020, by Derick Rethans
> 
> + grep 'log_errors =' /etc/php/7.4/cli/php.ini
> ;log_errors = On
> 
> + grep 'error_log =' /etc/php/7.4/cli/php.ini
> ;error_log = php_errors.log
> ;error_log = syslog
> error_log = /var/log/error.log
> 
> + php -r 'error_log('\''abc'\'');'
> 
> + tail -n 1 /var/log/error.log
> [18-Nov-2020 16:27:59 Europe/Berlin] abc
> 
> + sleep 3
> 
> + php -r 'error_log('\''abc'\'');'
> 
> + tail -n 1 /var/log/error.log
> [18-Nov-2020 16:28:02 Europe/Berlin] abc
> 
> As you can see the file is written: 16:27:59 < 16:28:02
> But why?

test again after you commented error_log.

-- 

  //Aho

[toc] | [prev] | [next] | [standalone]


#18407

Fromalex <1j9448a02@lnx159sneakemail.com.invalid>
Date2020-11-18 17:25 +0100
Message-ID<rp3ht8$146i$1@gioia.aioe.org>
In reply to#18406
Il 18/11/20 17:09, J.O. Aho ha scritto:
> On 18/11/2020 16.39, alex wrote:
>> Il 18/11/20 14:12, J.O. Aho ha scritto:
>>> On 18/11/2020 09.36, alex wrote:
>>>> $ grep 'log_errors =' /etc/php/7.4/cli/php.ini
>>>> log_errors = Off
>>>>
>>>> $ date && php -r "error_log('abc');" && ls -l /var/log/error.log
>>>> mer 18 nov 2020, 09:25:58, CET
>>>> -rw-rw-r-- 1 xxx yyy 25931 nov 18 09:25 /var/log/error.log
>>>>
>>>> As you can see log_errors is Off, but it seems that the log file is 
>>>> written: just compare the current date with the file date.
>>>>
>>>> Why?
>>>
>>> Did you do a tail /var/log/error.log to see that it was your message 
>>> that was written there and not something else that just happen to 
>>> have the same minute for it's log write?
>>>
>>> Are you sure your php cli is version 7.4?
>>>
>>> did you try to just comment it out by placing ; as the first 
>>> character of the line? Sometimes non-visible characters may cause 
>>> problems.
>>> (default value is Off)
>>>
>>> did you uncomment error_log = syslog or set a custom file?
>>>
>>
>> + php -v
>> PHP 7.4.3 (cli) (built: Oct  6 2020 15:47:56) ( NTS )
>> Copyright (c) The PHP Group
>> Zend Engine v3.4.0, Copyright (c) Zend Technologies
>>      with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
>>      with Xdebug v2.9.2, Copyright (c) 2002-2020, by Derick Rethans
>>
>> + grep 'log_errors =' /etc/php/7.4/cli/php.ini
>> ;log_errors = On
>>
>> + grep 'error_log =' /etc/php/7.4/cli/php.ini
>> ;error_log = php_errors.log
>> ;error_log = syslog
>> error_log = /var/log/error.log
>>
>> + php -r 'error_log('\''abc'\'');'
>>
>> + tail -n 1 /var/log/error.log
>> [18-Nov-2020 16:27:59 Europe/Berlin] abc
>>
>> + sleep 3
>>
>> + php -r 'error_log('\''abc'\'');'
>>
>> + tail -n 1 /var/log/error.log
>> [18-Nov-2020 16:28:02 Europe/Berlin] abc
>>
>> As you can see the file is written: 16:27:59 < 16:28:02
>> But why?
> 
> test again after you commented error_log.
> 

It works, but I wanted to do it through *log_errors* setting.
Otherwise, what is this setting for?

[toc] | [prev] | [next] | [standalone]


#18408

FromLew Pitcher <lew.pitcher@digitalfreehold.ca>
Date2020-11-18 17:39 +0000
Message-ID<rp3m7v$lh5$1@dont-email.me>
In reply to#18407
On Wed, 18 Nov 2020 17:25:13 +0100, alex wrote:

> Il 18/11/20 17:09, J.O. Aho ha scritto:
>> On 18/11/2020 16.39, alex wrote:
>>> Il 18/11/20 14:12, J.O. Aho ha scritto:
>>>> On 18/11/2020 09.36, alex wrote:
>>>>> $ grep 'log_errors =' /etc/php/7.4/cli/php.ini log_errors = Off
>>>>>
>>>>> $ date && php -r "error_log('abc');" && ls -l /var/log/error.log mer
>>>>> 18 nov 2020, 09:25:58, CET -rw-rw-r-- 1 xxx yyy 25931 nov 18 09:25
>>>>> /var/log/error.log
>>>>>
>>>>> As you can see log_errors is Off, but it seems that the log file is
>>>>> written: just compare the current date with the file date.
>>>>>
>>>>> Why?
>>>>
>>>> Did you do a tail /var/log/error.log to see that it was your message
>>>> that was written there and not something else that just happen to
>>>> have the same minute for it's log write?
>>>>
>>>> Are you sure your php cli is version 7.4?
>>>>
>>>> did you try to just comment it out by placing ; as the first
>>>> character of the line? Sometimes non-visible characters may cause
>>>> problems.
>>>> (default value is Off)
>>>>
>>>> did you uncomment error_log = syslog or set a custom file?
>>>>
>>>>
>>> + php -v PHP 7.4.3 (cli) (built: Oct  6 2020 15:47:56) ( NTS )
>>> Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend
>>> Technologies
>>>      with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
>>>      with Xdebug v2.9.2, Copyright (c) 2002-2020, by Derick
>>>      Rethans
>>>
>>> + grep 'log_errors =' /etc/php/7.4/cli/php.ini ;log_errors = On
>>>
>>> + grep 'error_log =' /etc/php/7.4/cli/php.ini ;error_log =
>>> php_errors.log ;error_log = syslog error_log = /var/log/error.log
>>>
>>> + php -r 'error_log('\''abc'\'');'
>>>
>>> + tail -n 1 /var/log/error.log [18-Nov-2020 16:27:59 Europe/Berlin]
>>> abc
>>>
>>> + sleep 3
>>>
>>> + php -r 'error_log('\''abc'\'');'
>>>
>>> + tail -n 1 /var/log/error.log [18-Nov-2020 16:28:02 Europe/Berlin]
>>> abc
>>>
>>> As you can see the file is written: 16:27:59 < 16:28:02 But why?
>> 
>> test again after you commented error_log.
>> 
>> 
> It works, but I wanted to do it through *log_errors* setting.
> Otherwise, what is this setting for?

The way I read the PHP documentation on error-logging
(https://www.php.net/manual/en/errorfunc.configuration.php), the 
log_errors and error_log settings select between one of FOUR possible 
configurations.

1: with log_errors set to FALSE, php will log errors to the SAPI error log
   (for Apache, this would be where-ever the apache error log goes).

2: With log_errors set to TRUE, and error_log not set, php will log
   errors to the SAPI error log (for Apache, this would be where-ever the
   apache error log goes).

3: With log_errors set to TRUE, and error_log set to "syslog", php will
   log errors to the system logging mechanism (syslog on Unix, Event log
   on Windows)

4: With log_errors set to TRUE, and error_log set to something other than
   "syslog", php will log errors to the file named by error_log.

So, to manipulate error logging /exclusively/ through error_log, you need 
to set log_errors to TRUE (or YES, or whatever boolean suits), then set 
error_log to either NULL (to log errors to the SAPI error log), or  
"syslog" (to log errors to your system logging mechanism) or a file path 
(to log errors to that file).


HTH
-- 
Lew Pitcher
"In Skills, We Trust"

[toc] | [prev] | [next] | [standalone]


#18412

Fromalex <1j9448a02@lnx159sneakemail.com.invalid>
Date2020-11-19 16:27 +0100
Message-ID<rp62sj$kir$1@gioia.aioe.org>
In reply to#18408
Il 18/11/20 18:39, Lew Pitcher ha scritto:

First of all I hope that I have understood the last things you write.

> So, to manipulate error logging/exclusively/  through error_log, you need
> to set log_errors to TRUE (or YES, or whatever boolean suits), then set
> error_log to either NULL (to log errors to the SAPI error log), or
> "syslog" (to log errors to your system logging mechanism) or a file path
> (to log errors to that file).

Therefore:

$ cat test.php
<?php
var_dump(ini_get('log_errors'));
ini_set('error_log', '/var/log/error.log');
error_log('abcxyz123');

$ php test.php
/tmp/tmp.eX4LOsdST6/test.php:2:
string(1) "0"

string(1) "0": suggests that logging is disabled
Quite right?

$ grep abcxyz123 /var/log/error.log
[19-Nov-2020 16:15:47 Europe/Berlin] abcxyz123

But something is not right :(

[toc] | [prev] | [next] | [standalone]


#18410

FromArno Welzel <usenet@arnowelzel.de>
Date2020-11-19 15:42 +0100
Message-ID<i1neijF6l51U1@mid.individual.net>
In reply to#18403
alex:

> $ grep 'log_errors =' /etc/php/7.4/cli/php.ini
> log_errors = Off

That's not relevant.

Check what

php -i | grep log_errors

says.

> $ date && php -r "error_log('abc');" && ls -l /var/log/error.log
> mer 18 nov 2020, 09:25:58, CET
> -rw-rw-r-- 1 xxx yyy 25931 nov 18 09:25 /var/log/error.log
> 
> As you can see log_errors is Off, but it seems that the log file is 
> written: just compare the current date with the file date.
> 
> Why?

Are you sure, PHP 7.4 is the one which is called using php? Check with

php -v


-- 
Arno Welzel
https://arnowelzel.de

[toc] | [prev] | [next] | [standalone]


#18414

Fromalex <1j9448a02@lnx159sneakemail.com.invalid>
Date2020-11-19 19:22 +0100
Message-ID<rp6d5l$2qc$1@gioia.aioe.org>
In reply to#18410
Il 19/11/20 15:42, Arno Welzel ha scritto:
>> $ date && php -r "error_log('abc');" && ls -l /var/log/error.log
>> mer 18 nov 2020, 09:25:58, CET
>> -rw-rw-r-- 1 xxx yyy 25931 nov 18 09:25 /var/log/error.log
>>
>> As you can see log_errors is Off, but it seems that the log file is
>> written: just compare the current date with the file date.
>>
>> Why?
> 
> Are you sure, PHP 7.4 is the one which is called using php? Check with
> 
> php -v
> 
> 

$ php -v
PHP 7.4.3 (cli) (built: Oct  6 2020 15:47:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
     with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
     with Xdebug v2.9.2, Copyright (c) 2002-2020, by Derick Rethans

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web