I stuck with this issue, googled it around and got some solutions but unlikely it is not working properly. Can anyone give a solution for this please,
I'm running Apache2 in Ubuntu 14.04 machine. Have only one virtual host running in it
and have a document root under /var/www/html
where our resides.
Inside html directory our code contains sub-directories. For eg. dir1, dir2. I need the error log should be customized like all the error log related to code under dir1 should resides inside dir1 and same for dir2.
How I can customize the error logs?
According this post https://stackoverflow.com/questions/10395043/apache-server-multiple-directories-different-error-logs
It is not doable for the error log as ErrorLog directive works only in server config or virtual host context. It is possible to separate AccessLog with features provided by setenvif module.
Alternatively one can try something like that:
ErrorLog "|/usr/bin/tee -a ${APACHE_LOG_DIR}/error.log /var/www/apachelogs/error.txt"
Just put more sophisticated filtering script in between and may be you manage to achieve what you need.
Some nitpicking, why would you need error log in the directory with code ? Imho it is a security threat.
I believe this is what you want:
Source:
https://stackoverflow.com/questions/1460757/generate-access-logs-for-different-subdirectories-in-apache
Simply use in your vhost
and it will write error file in the same folder in which the script causing the error resides.
An error in
will write the error in