7

Rather than put the absolute path to an error_log in my .htaccess, I would like to find a way to specify it relative to the .htaccess file (or similar):

php_value error_log %{DOCUMENT_ROOT}/libs/log/error/PHP_errors.log

It would be something like I would want to do, but this doesn't seem to work. If I specify the absolute, it does work.

4
  • What happens if you set it to ./path/error.log? Commented Jul 4, 2012 at 13:34
  • @jexact genius! add it as an answer and i'll mark it as correct. Commented Jul 4, 2012 at 13:46
  • now i just need to figure out how to only log fatal errors. Commented Jul 4, 2012 at 13:47
  • Just change the error reporting level. Example: php_value error_reporting 21 (equals to error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR)) Here you can find other values: PHP: Predefined Constants Commented Jul 4, 2012 at 14:14

2 Answers 2

4

You can set it to ./path/error.log.

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

2 Comments

While this works, it's relative to the location of the currently executing php file. So if you run some code in other folders, then the location of the error log will move relative to that. IMO its not very useful in that case because most people will use some folders.
Excuse the necro, but O'Roony just saved me a lot of debugging time. I kept wondering why the heck my logs were appearing in the wrong folders. So definitely don't use the ./path method unless you've got all requests routed to an index.php file or something.
2

When you have access to the server-config httpd.conf file, you can add the Line:

# set this to your document-root path
Define DOCROOT   "d:\htdocs"

and in your htaccess you can write:

php_value error_log ${DOCROOT}/libs/log/error/PHP_errors.log

With this define you can even replace all other places where your document root is use e.g.

DocumentRoot "${DOCROOT}"

@see: https://httpd.apache.org/docs/2.4/de/mod/core.html#define

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.