alanoncl Posted October 21 Posted October 21 (edited) hi... firstly, i dont know if this is the correct place to post this question.. i supossed so because is related to some hh feature i have a php script that writes some info with php custom_log() with a log type 3 "custom file" file like: error_log($msg, $severity, 3, $custom_file) (i guess file_put_contents() works in same manner internally) so... for keep things clean, i want the file to be located in <hh_home>/logs/mylog.log .... but nothing is written to the file! .. i just added the file to "add custom log" in webhosting section but still the same... i have another included file read like $_SERVER['DOCUMENT_ROOT'].'/../includes/myInclude.php that works flawlessly, maybe because /logs folder is special?, or have different owner/permissions? am i doing something wrong?? .. please help me somebody who knows Edited October 21 by alanoncl
Haradion Posted October 25 Posted October 25 Well, to test the permissions, you could see if you can write to the file with any other functions, e.g. file_put_contents.
alanoncl Posted November 2 Author Posted November 2 (edited) thanks for your suggestions Haradion ... i did some tests with error_log() and file_put_contents(), and discovered the problem is error_log() function with type 3 (at least) because file_put_contents() worked flawlessly in every directory i tested so i think i will switch my log function to file_put_contents() with append flag ... until maybe is not the optimal or so elegant (because of performance or security), but at least it seem to work if some staff member read this thread and feel motivated, may be good if check this issue and/or document it because possible performance and security risks... and to avoid being walking blind while a mess is happening because somebody could think "no log = no problem" thanks Edited November 2 by alanoncl
wolstech Posted November 2 Posted November 2 The error_log() function works fine. I created a file in httpdocs for you called test_error_log.php and ran it by visiting it in a browser. It created a log in your logs folder called testerror.log without issue. The logs folder does have special permissions so the web server can write to it, but they won't affect the ability of error_log to write files in there. Also, error_log() requires a file system path from the root of the server (e.g. /home/al-anon.cl/logs/testerror.log), not a URL or a relative path ( ../ )
alanoncl Posted November 4 Author Posted November 4 (edited) hi wolstech, thanks for answering maybe i am doing something wrong .. this is what i tried: created an "includes" folder in my home directory in that folder create a library file that includes "error_log($msg."\n", $level, 3, $my_log);" (here "3" means append log to file on next parameter) $my_log = $_SERVER['DOCUMENT_ROOT'].'/../logs/mailer.log' , because php sees document root as httpdocs folder, this trick worked me before include this lib at top in some httpdocs php script with "include_once $_SERVER['DOCUMENT_ROOT'].'/../includes/my_lib.php';" howerev it doesn't log anything... but if i just replace error_log() with file_put_contents() it works ok ... so that is what i did, blindly without understand why i hope this info would be useful to reproduce the issue and help debugging, or to workaround it Edited November 4 by alanoncl i suck with english
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now