简体   繁体   中英

How do I set the PHP error_log to the home directory in php.ini?

I have access to the server-wide PHP settings on a server with shared hosting. Currently the error_log value is simply "error_log", meaning it logs errors to a file named error_log in the same directory as the script that caused the error. This results in error_log files in the web directory. Even though outsiders can't see the files, I'm not comfortable with them being there all the same. I could specify an exact log file path, but I don't want errors of all the sites to end up in one file. I know that setting error_log to be "~/error_log" will not work (that is, it will NOT put the file in the home directory of whatever website generates the error). Any suggestions on how I can accomplish that? I suppose I need to use an auto-prepended script?

Yes, I know I could override the global php.ini error_log settings with a php.ini file in every site's home directory, however there are a lot of sites, and I don't want to have to remember to do this with every site added.

您可以使用ini_set函数:

   ini_set("error_log", "/yourhome/yourproject.log");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM