• [docker] error_log() not write inside web page

    From SupaPlex@old@gamer.s to comp.lang.php on Sat Nov 26 21:30:56 2022
    From Newsgroup: comp.lang.php

    supaplex$ cat docker-compose.yml
    services:
    web:
    image: php:apache
    ports:
    - 8013:80
    volumes:
    - .:/var/www/html

    supaplex$ cat index.php
    <?php
    echo "BEFORE\n";
    error_log("abc");
    echo "AFTER\n";

    supaplex$ docker-compose up -d
    supaplex_web_1 is up-to-date

    $ docker-compose run web php index.php
    Creating supaplex_web_run ... done
    BEFORE
    abc
    AFTER

    OK, but...

    supaplex$ curl http://localhost:8013/
    BEFORE
    AFTER

    Why *abc* does not appear?
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Arno Welzel@usenet@arnowelzel.de to comp.lang.php on Tue Nov 29 21:20:13 2022
    From Newsgroup: comp.lang.php

    SupaPlex, 2022-11-26 21:30:

    [...]
    <?php
    echo "BEFORE\n";
    error_log("abc");
    echo "AFTER\n";
    [...]
    supaplex$ curl http://localhost:8013/
    BEFORE
    AFTER

    Why *abc* does not appear?

    Because error_log() does not produce any output:

    <https://www.php.net/manual/en/function.error-log.php>

    "error_log rCo Send an error message to the defined error handling routines"

    And the error handling routines may not send the log message to the
    output but only to the error log which is *not* send via HTTP to the client.

    Next time please read the PHP manuals first, before asking here.
    --
    Arno Welzel
    https://arnowelzel.de

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From SupaPlex@old@gamer.s to comp.lang.php on Wed Nov 30 10:24:24 2022
    From Newsgroup: comp.lang.php

    Il 29/11/22 21:20, Arno Welzel ha scritto:
    Because error_log() does not produce any output:

    <https://www.php.net/manual/en/function.error-log.php>

    "error_log rCo Send an error message to the defined error handling routines"

    And the error handling routines may not send the log message to the
    output but only to the error log which is *not* send via HTTP to the client.

    Next time please read the PHP manuals first, before asking here.

    Practically error_log() varies its behavior based on the API server (https://www.php.net/manual/en/function.php-sapi-php)?
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From SupaPlex@old@gamer.s to comp.lang.php on Wed Nov 30 10:33:45 2022
    From Newsgroup: comp.lang.php

    Il 30/11/22 10:24, SupaPlex ha scritto:
    Il 29/11/22 21:20, Arno Welzel ha scritto:
    Because error_log() does not produce any output:

    <https://www.php.net/manual/en/function.error-log.php>

    "error_log rCo Send an error message to the defined error handling
    routines"

    And the error handling routines may not send the log message to the
    output but only to the error log which is *not* send via HTTP to the
    client.

    Next time please read the PHP manuals first, before asking here.

    Practically error_log() varies its behavior based on the API server (https://www.php.net/manual/en/function.php-sapi-php)?

    Sorry
    https://www.php.net/manual/en/function.php-sapi-name.php
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From J.O. Aho@user@example.net to comp.lang.php on Wed Nov 30 11:26:30 2022
    From Newsgroup: comp.lang.php

    On 30/11/2022 10.24, SupaPlex wrote:
    Il 29/11/22 21:20, Arno Welzel ha scritto:
    Because error_log() does not produce any output:

    <https://www.php.net/manual/en/function.error-log.php>

    "error_log rCo Send an error message to the defined error handling
    routines"

    And the error handling routines may not send the log message to the
    output but only to the error log which is *not* send via HTTP to the
    client.

    Next time please read the PHP manuals first, before asking here.

    Practically error_log() varies its behavior based on the API server (https://www.php.net/manual/en/function.php-sapi-name.php)?

    I would say the API that the web server uses to talk with the PHP engine
    will not change the behavior, what you are looking for is

    ; This directive controls whether or not and where PHP will output errors,
    ; notices and warnings too. Error output is very useful during
    development, but
    ; it could be very dangerous in production environments. Depending on
    the code
    ; which is triggering the error, sensitive information could potentially
    leak
    ; out of your application such as database usernames and passwords or worse.
    ; For production environments, we recommend logging errors rather than
    ; sending them to STDOUT.
    ; Possible Values:
    ; Off = Do not display any errors
    ; stderr = Display errors to STDERR (affects only CGI/CLI binaries!)
    ; On or stdout = Display errors to STDOUT
    ;
    ; Development Value: On
    ; Production Value: Off
    ; https://php.net/display-errors
    display_errors = Off
    --
    //Aho




    --- Synchronet 3.21d-Linux NewsLink 1.2