3

Does PHP create the directory for the error log if it does not exist?

For example, the error_log directive is set to /var/logs/php/errors.log but the folder /var/logs/php does not exist.

3
  • Gooood question, I liked Commented Sep 1, 2013 at 8:46
  • 1
    Well, create a PHP file and put an error in it. See what happens. Was the folder created? I do not mean to sound patronizing, but this seems like something you can figure out by just trying it out. Commented Sep 1, 2013 at 8:48
  • 2
    @SverriM.Olsen: The moment you submitted your comment, all that was already done. It would have only required you to look not only at the question but also at the answer. The "answer your own question" kind posting has been done here. Commented Jul 11, 2015 at 12:32

1 Answer 1

8

No, this is not the case. If the directory for the logfile does not exist, it is not automatically created.

If you log only errors to file, no errors will be logged and no notice about that is given.

Tested with PHP 5.4.13

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

1 Comment

@Fluffeh: I dunno if that qualifies as a bug. It might be considered a flaw from some perspective but as this is I/O bound I personally do not think that it should be created. Also this can have serious security implications, before I judge about it I would consult a sysadmin first. It's just I needed to find out and googling didn't went well so I Q&A'ed it here for future reference.

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.