1

PHP 7.2. When I use:

error_log('test');

in the error log I see an entry:

[31-Jan-2020 20:05:28 UTC] test

(note the date/time in the beginning of the line)

When I use:

error_log('test',3, 'my_error_log');

I just got:

test

in the 'my_error_log' file - there is no date time at the beginning. Even new lines are not added automatically.

Why two error_log calls produce different output? How can I control it?

1 Answer 1

3

In the first case, the error_log probably outputs to the default log file whose location depends on the server's software which prepends your message with a datetime string. error_log does not prepend strings.

Even new lines are not added automatically.

According to the PHP docs, when you choose message_type with a value of 3, new lines aren't automatically added. https://www.php.net/manual/en/function.error-log.php

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.