1

Is there an easy way to log PHP errors to a log for a specific script. So say I have 5 different scripts each one would have its own error log?

1
  • 4
    The answer for that is yes, there is a way. Commented Jul 3, 2012 at 15:33

5 Answers 5

5

You can modify the name of the log file, by using ini_set() (PHP docu) in conjunction with error_log (PHP docu):

ini_set( 'error_log', 'yourFileName' );

If you specify a different file in each script, you will have seperate log files for them all.

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

Comments

4

Yes, you could have separate set_error_handler for each script.

1 Comment

You don't even need a separate error handler for each. If you do it correctly, you can have a single one for all 5.
1

See error_log. Other than that, you can use ini_set (see Sirko's answer)

Comments

0

you could simply create that on your own. http://php.net/manual/de/function.file-put-contents.php

Just build a small function and call it in every of your 5 scripts.

Comments

0

If you're doing this purely under Apache, you can hack together something like:

<Location /path/to/script1.php>
   php_value error_log script1.log
</Location>

<Location /path/to/script2.php>
    php_value error_log script2.log
</Location>

etc...

in your .htaccess/httpd.conf.

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.