How to set error_log folder by folder

My company has a large hosting, but it is not managed by us, we do not see configuration files, but I want to answer this function on our local test server.

Im new to my company and I want to start some debugging applications to fix some problems with minors and majors for clients, but the number of files is so large that one error_file is huge .. and there are many people working on it, so every time I check log (30 seconds to 1 minute) contains hundreds of lines added.

I don't know if this is installed on apache, via .htaccess files or on php.ini

I will appreciate any advice on this.

- EDIT -

I am talking about PHP errors, but as I say, I do not know if this is installed on php or apache or, possibly, using a third-party library.

I'm not talking about setting up a specific error_log folder, IM error messages are written to the scripts folder.

Example: I create a folder called test1, inside I make some buggy php script that throws some errors, when I run the script, I can see the error_log file created in this folder. So it works on the fly.

I tried to ask the hosting company support how they do it, but they do not answer me.


I donโ€™t know, maybe there might be some kind of Cpanel setup (BTW Hosting Support stuff doesnโ€™t understand this question, but okay .. usually Level 1 support cannot handle technical things)

+4
source share
3 answers

I don't know if anyone needs to use this, but I found it.

You must set the php.ini file directive as follows, the line "error_log" on the right side is the name of the u file that is required for the log,

error_log = error_log 

This will create a php error log in the folder where the script is executed,

I will try to explain

script test.php in the folder / www / site / lib

 include "./db_conn.php"; 

If db_conn.php is not in the same directory, this will lead to a warning and an error, usually it will lead to the serve / vhost log, but with this directive you will get the error_log file under the / www / site / lib directory.

Why I watched or this, well, as I wrote, I wrote them work on a huge application, with thousands of files there are a lot of fire warnings, notifications, etc. I'm not the only one in the project and the error_log site was so huge as to track the evolution of debugging for one or more files, now I just need to track the log from the dirs where they work.

I hope this can be useful to everyone. Thanks for the sugestions and excuse my english its not very good

+12
source

you can manage the logs by adding this to your vhost or htaccess

 ErrorLog /path/to/a/writable/directory/error.log 

For more information see the article on advanced php error handling via htaccess

0
source

To do this in PHP, edit php.ini and add the line

 error_log = /path/to/where/you/want/your/php-errors.log 

Then restart the web server. This should give you PHP errors and only PHP errors for this file. Provided, of course, that the scripts are not written to throw away all the errors.

To do this in Apache, you can use SetEnvIf to add an environment variable to any request ending in php, and then to print all the logs using this particular environment variable. For instance:

 SetEnvIf Request_URI "\.php$" phplog CustomLog /path/to/php.log env=phplog 

To use this in multiple folders, create one environment variable for each folder and one CustomLog for each folder, for example:

 SetEnvIf Request_URI "/folder1/.*\.php$" log_folder1 Customlog /path/to/folder1/php.log env=log_folder1 SetEnvIf Request_URI "/folder2/.*\.php$" log_folder2 Customlog /path/to/folder2/php.log env=log_folder2 
0
source

Source: https://habr.com/ru/post/1411316/


All Articles