Custom apache error logs for the directories inside the document root
up vote
1
down vote
favorite
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?
14.04 apache2 log error-handling
add a comment |
up vote
1
down vote
favorite
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?
14.04 apache2 log error-handling
Why not separate them in 2 different virtual hosts?
– Dan
Aug 31 '17 at 7:20
No. Customer don't want us to do that Dan!
– harsha
Aug 31 '17 at 7:22
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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?
14.04 apache2 log error-handling
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?
14.04 apache2 log error-handling
14.04 apache2 log error-handling
edited Nov 29 at 9:27
Mr Shunz
2,2091922
2,2091922
asked Aug 31 '17 at 6:19
harsha
769
769
Why not separate them in 2 different virtual hosts?
– Dan
Aug 31 '17 at 7:20
No. Customer don't want us to do that Dan!
– harsha
Aug 31 '17 at 7:22
add a comment |
Why not separate them in 2 different virtual hosts?
– Dan
Aug 31 '17 at 7:20
No. Customer don't want us to do that Dan!
– harsha
Aug 31 '17 at 7:22
Why not separate them in 2 different virtual hosts?
– Dan
Aug 31 '17 at 7:20
Why not separate them in 2 different virtual hosts?
– Dan
Aug 31 '17 at 7:20
No. Customer don't want us to do that Dan!
– harsha
Aug 31 '17 at 7:22
No. Customer don't want us to do that Dan!
– harsha
Aug 31 '17 at 7:22
add a comment |
3 Answers
3
active
oldest
votes
up vote
0
down vote
I believe this is what you want:
SetEnvIf Request_URI ^/app/subapp1(/|$) subapp1
SetEnvIf Request_URI ^/app/subapp2(/|$) subapp2
CustomLog /absolute/path/to/app/subapp1/log/access_log common env=subapp1
CustomLog /absolute/path/to/app/subapp2/log/access_log common env=subapp2
Source:
https://stackoverflow.com/questions/1460757/generate-access-logs-for-different-subdirectories-in-apache
Thanks for the reply George. I already tried this solution, it is working for access_logs but not for error.logs.
– harsha
Aug 31 '17 at 6:53
Even when you edit the name to ErrorLog?
– George Udosen
Aug 31 '17 at 6:56
Please see this: stackoverflow.com/questions/10395043/…
– George Udosen
Aug 31 '17 at 7:05
CustomLog /var/www/html/app1/error.log env=app1 ErrorLog /var/www/html/app1/error.log CustomLog /var/www/html/app2/error.log env=app2 ErrorLog /var/www/html/app2/error.log This is how I edited for error.log. Is it correct?
– harsha
Aug 31 '17 at 7:05
I tried even that, I got this error AH00526: Syntax error on line 50 of /etc/apache2/sites-enabled/000-default.conf: ErrorLog takes one argument, The filename of the error log
– harsha
Aug 31 '17 at 7:14
|
show 8 more comments
up vote
0
down vote
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.
Thanks mestia. The solution which you have suggested, I guess it will not separate the logs based on directories. We need this because each developers are working on different directory (code ). They want to know whats the error they are getting particularly for the code which they are working on.
– harsha
Aug 31 '17 at 7:12
In this case I guess you can set a variable with setenvif and place this variable to the error log file by adjusting the error log directive and adding logging of %{VARNAME}e. is this works just filter the corresponding values before giving them to the developers.
– mestia
Aug 31 '17 at 7:28
add a comment |
up vote
0
down vote
Simply use in your vhost
ErrorLog error.log
and it will write error file in the same folder in which the script causing the error resides.
An error in
http://example.com/some/dir/test.php
will write the error in
/public_html/some/dir/error.log
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I believe this is what you want:
SetEnvIf Request_URI ^/app/subapp1(/|$) subapp1
SetEnvIf Request_URI ^/app/subapp2(/|$) subapp2
CustomLog /absolute/path/to/app/subapp1/log/access_log common env=subapp1
CustomLog /absolute/path/to/app/subapp2/log/access_log common env=subapp2
Source:
https://stackoverflow.com/questions/1460757/generate-access-logs-for-different-subdirectories-in-apache
Thanks for the reply George. I already tried this solution, it is working for access_logs but not for error.logs.
– harsha
Aug 31 '17 at 6:53
Even when you edit the name to ErrorLog?
– George Udosen
Aug 31 '17 at 6:56
Please see this: stackoverflow.com/questions/10395043/…
– George Udosen
Aug 31 '17 at 7:05
CustomLog /var/www/html/app1/error.log env=app1 ErrorLog /var/www/html/app1/error.log CustomLog /var/www/html/app2/error.log env=app2 ErrorLog /var/www/html/app2/error.log This is how I edited for error.log. Is it correct?
– harsha
Aug 31 '17 at 7:05
I tried even that, I got this error AH00526: Syntax error on line 50 of /etc/apache2/sites-enabled/000-default.conf: ErrorLog takes one argument, The filename of the error log
– harsha
Aug 31 '17 at 7:14
|
show 8 more comments
up vote
0
down vote
I believe this is what you want:
SetEnvIf Request_URI ^/app/subapp1(/|$) subapp1
SetEnvIf Request_URI ^/app/subapp2(/|$) subapp2
CustomLog /absolute/path/to/app/subapp1/log/access_log common env=subapp1
CustomLog /absolute/path/to/app/subapp2/log/access_log common env=subapp2
Source:
https://stackoverflow.com/questions/1460757/generate-access-logs-for-different-subdirectories-in-apache
Thanks for the reply George. I already tried this solution, it is working for access_logs but not for error.logs.
– harsha
Aug 31 '17 at 6:53
Even when you edit the name to ErrorLog?
– George Udosen
Aug 31 '17 at 6:56
Please see this: stackoverflow.com/questions/10395043/…
– George Udosen
Aug 31 '17 at 7:05
CustomLog /var/www/html/app1/error.log env=app1 ErrorLog /var/www/html/app1/error.log CustomLog /var/www/html/app2/error.log env=app2 ErrorLog /var/www/html/app2/error.log This is how I edited for error.log. Is it correct?
– harsha
Aug 31 '17 at 7:05
I tried even that, I got this error AH00526: Syntax error on line 50 of /etc/apache2/sites-enabled/000-default.conf: ErrorLog takes one argument, The filename of the error log
– harsha
Aug 31 '17 at 7:14
|
show 8 more comments
up vote
0
down vote
up vote
0
down vote
I believe this is what you want:
SetEnvIf Request_URI ^/app/subapp1(/|$) subapp1
SetEnvIf Request_URI ^/app/subapp2(/|$) subapp2
CustomLog /absolute/path/to/app/subapp1/log/access_log common env=subapp1
CustomLog /absolute/path/to/app/subapp2/log/access_log common env=subapp2
Source:
https://stackoverflow.com/questions/1460757/generate-access-logs-for-different-subdirectories-in-apache
I believe this is what you want:
SetEnvIf Request_URI ^/app/subapp1(/|$) subapp1
SetEnvIf Request_URI ^/app/subapp2(/|$) subapp2
CustomLog /absolute/path/to/app/subapp1/log/access_log common env=subapp1
CustomLog /absolute/path/to/app/subapp2/log/access_log common env=subapp2
Source:
https://stackoverflow.com/questions/1460757/generate-access-logs-for-different-subdirectories-in-apache
answered Aug 31 '17 at 6:40
George Udosen
18.9k94266
18.9k94266
Thanks for the reply George. I already tried this solution, it is working for access_logs but not for error.logs.
– harsha
Aug 31 '17 at 6:53
Even when you edit the name to ErrorLog?
– George Udosen
Aug 31 '17 at 6:56
Please see this: stackoverflow.com/questions/10395043/…
– George Udosen
Aug 31 '17 at 7:05
CustomLog /var/www/html/app1/error.log env=app1 ErrorLog /var/www/html/app1/error.log CustomLog /var/www/html/app2/error.log env=app2 ErrorLog /var/www/html/app2/error.log This is how I edited for error.log. Is it correct?
– harsha
Aug 31 '17 at 7:05
I tried even that, I got this error AH00526: Syntax error on line 50 of /etc/apache2/sites-enabled/000-default.conf: ErrorLog takes one argument, The filename of the error log
– harsha
Aug 31 '17 at 7:14
|
show 8 more comments
Thanks for the reply George. I already tried this solution, it is working for access_logs but not for error.logs.
– harsha
Aug 31 '17 at 6:53
Even when you edit the name to ErrorLog?
– George Udosen
Aug 31 '17 at 6:56
Please see this: stackoverflow.com/questions/10395043/…
– George Udosen
Aug 31 '17 at 7:05
CustomLog /var/www/html/app1/error.log env=app1 ErrorLog /var/www/html/app1/error.log CustomLog /var/www/html/app2/error.log env=app2 ErrorLog /var/www/html/app2/error.log This is how I edited for error.log. Is it correct?
– harsha
Aug 31 '17 at 7:05
I tried even that, I got this error AH00526: Syntax error on line 50 of /etc/apache2/sites-enabled/000-default.conf: ErrorLog takes one argument, The filename of the error log
– harsha
Aug 31 '17 at 7:14
Thanks for the reply George. I already tried this solution, it is working for access_logs but not for error.logs.
– harsha
Aug 31 '17 at 6:53
Thanks for the reply George. I already tried this solution, it is working for access_logs but not for error.logs.
– harsha
Aug 31 '17 at 6:53
Even when you edit the name to ErrorLog?
– George Udosen
Aug 31 '17 at 6:56
Even when you edit the name to ErrorLog?
– George Udosen
Aug 31 '17 at 6:56
Please see this: stackoverflow.com/questions/10395043/…
– George Udosen
Aug 31 '17 at 7:05
Please see this: stackoverflow.com/questions/10395043/…
– George Udosen
Aug 31 '17 at 7:05
CustomLog /var/www/html/app1/error.log env=app1 ErrorLog /var/www/html/app1/error.log CustomLog /var/www/html/app2/error.log env=app2 ErrorLog /var/www/html/app2/error.log This is how I edited for error.log. Is it correct?
– harsha
Aug 31 '17 at 7:05
CustomLog /var/www/html/app1/error.log env=app1 ErrorLog /var/www/html/app1/error.log CustomLog /var/www/html/app2/error.log env=app2 ErrorLog /var/www/html/app2/error.log This is how I edited for error.log. Is it correct?
– harsha
Aug 31 '17 at 7:05
I tried even that, I got this error AH00526: Syntax error on line 50 of /etc/apache2/sites-enabled/000-default.conf: ErrorLog takes one argument, The filename of the error log
– harsha
Aug 31 '17 at 7:14
I tried even that, I got this error AH00526: Syntax error on line 50 of /etc/apache2/sites-enabled/000-default.conf: ErrorLog takes one argument, The filename of the error log
– harsha
Aug 31 '17 at 7:14
|
show 8 more comments
up vote
0
down vote
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.
Thanks mestia. The solution which you have suggested, I guess it will not separate the logs based on directories. We need this because each developers are working on different directory (code ). They want to know whats the error they are getting particularly for the code which they are working on.
– harsha
Aug 31 '17 at 7:12
In this case I guess you can set a variable with setenvif and place this variable to the error log file by adjusting the error log directive and adding logging of %{VARNAME}e. is this works just filter the corresponding values before giving them to the developers.
– mestia
Aug 31 '17 at 7:28
add a comment |
up vote
0
down vote
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.
Thanks mestia. The solution which you have suggested, I guess it will not separate the logs based on directories. We need this because each developers are working on different directory (code ). They want to know whats the error they are getting particularly for the code which they are working on.
– harsha
Aug 31 '17 at 7:12
In this case I guess you can set a variable with setenvif and place this variable to the error log file by adjusting the error log directive and adding logging of %{VARNAME}e. is this works just filter the corresponding values before giving them to the developers.
– mestia
Aug 31 '17 at 7:28
add a comment |
up vote
0
down vote
up vote
0
down vote
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.
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.
answered Aug 31 '17 at 6:54
mestia
613
613
Thanks mestia. The solution which you have suggested, I guess it will not separate the logs based on directories. We need this because each developers are working on different directory (code ). They want to know whats the error they are getting particularly for the code which they are working on.
– harsha
Aug 31 '17 at 7:12
In this case I guess you can set a variable with setenvif and place this variable to the error log file by adjusting the error log directive and adding logging of %{VARNAME}e. is this works just filter the corresponding values before giving them to the developers.
– mestia
Aug 31 '17 at 7:28
add a comment |
Thanks mestia. The solution which you have suggested, I guess it will not separate the logs based on directories. We need this because each developers are working on different directory (code ). They want to know whats the error they are getting particularly for the code which they are working on.
– harsha
Aug 31 '17 at 7:12
In this case I guess you can set a variable with setenvif and place this variable to the error log file by adjusting the error log directive and adding logging of %{VARNAME}e. is this works just filter the corresponding values before giving them to the developers.
– mestia
Aug 31 '17 at 7:28
Thanks mestia. The solution which you have suggested, I guess it will not separate the logs based on directories. We need this because each developers are working on different directory (code ). They want to know whats the error they are getting particularly for the code which they are working on.
– harsha
Aug 31 '17 at 7:12
Thanks mestia. The solution which you have suggested, I guess it will not separate the logs based on directories. We need this because each developers are working on different directory (code ). They want to know whats the error they are getting particularly for the code which they are working on.
– harsha
Aug 31 '17 at 7:12
In this case I guess you can set a variable with setenvif and place this variable to the error log file by adjusting the error log directive and adding logging of %{VARNAME}e. is this works just filter the corresponding values before giving them to the developers.
– mestia
Aug 31 '17 at 7:28
In this case I guess you can set a variable with setenvif and place this variable to the error log file by adjusting the error log directive and adding logging of %{VARNAME}e. is this works just filter the corresponding values before giving them to the developers.
– mestia
Aug 31 '17 at 7:28
add a comment |
up vote
0
down vote
Simply use in your vhost
ErrorLog error.log
and it will write error file in the same folder in which the script causing the error resides.
An error in
http://example.com/some/dir/test.php
will write the error in
/public_html/some/dir/error.log
add a comment |
up vote
0
down vote
Simply use in your vhost
ErrorLog error.log
and it will write error file in the same folder in which the script causing the error resides.
An error in
http://example.com/some/dir/test.php
will write the error in
/public_html/some/dir/error.log
add a comment |
up vote
0
down vote
up vote
0
down vote
Simply use in your vhost
ErrorLog error.log
and it will write error file in the same folder in which the script causing the error resides.
An error in
http://example.com/some/dir/test.php
will write the error in
/public_html/some/dir/error.log
Simply use in your vhost
ErrorLog error.log
and it will write error file in the same folder in which the script causing the error resides.
An error in
http://example.com/some/dir/test.php
will write the error in
/public_html/some/dir/error.log
answered Nov 29 at 7:22
Sunil Gautam
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f951497%2fcustom-apache-error-logs-for-the-directories-inside-the-document-root%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Why not separate them in 2 different virtual hosts?
– Dan
Aug 31 '17 at 7:20
No. Customer don't want us to do that Dan!
– harsha
Aug 31 '17 at 7:22