php - how to write an individual error_log for each file

892

How can I set up a distinct separate error_log for each file?

I tried putting the following line in an include that goes in all files but didn't seem to work.

ini_set('error_log ', str_replace('.php', '', __FILE__));

Is there a way to do it?

205

Answer

Solution:

I solved this by declaring a new var before the include with the__FILE__ value.

$errorFileName = __FILE__;
include 'headers.php';

and inside the headers.php I check if that variable is set then use it to set the error_log.

if (isset($errorFileName)) {
  ini_set('error_log', str_replace('.php', '', $errorFileName));
}

People are also looking for solutions to the problem: php - Get specific columns using “with()” inside of another '

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.