php engine scripts execution logging

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I want to gain insight into the access and running of scripts by the
php engine on my production box.

Most scripts are executed via cronjobs and they invoke a lot of other
php scripts. I can backtrace these files, but a lot of other scripts
are run by our users from the command line and I want to know if it possible
to instruct the engine to log the names of these script files.

I use php version 4.3.6 and I tried to modify the php.ini file to enable
logging, but the logfile only reports errors and not the access/execution a

Is there a way to instruct the php engine to log the execution of


Re: php engine scripts execution logging


I found the solution myself, thank you ;)  just kiddin'
Ok, here's the solution : this works with version  4.3.6 (cli), mileage may
vary with other versions.
PHP uses php.ini (of course)  and with the lines

; Automatically add files before or after any PHP document.
auto_prepend_file =
auto_append_file = /usr/local/karoshi/src/logging/php-log.php

you can append or prepend a script after of before execution of the main
script. Here I state that after execution of the main script php should
execute php-log.php  (remember to fully quantify the path to the script).

Now let's take a look at php-log.php :


$current_exec ="";
$current_incl ="";

for ($index = 0; $index < $_SERVER['argc']; $index++)
 $current_exec .= " ".$_SERVER['argv'][$index];

$includes = get_included_files();

for ($index = 0; $index < sizeof(get_included_files()); $index++)
 $current_incl .= " ".$includes[$index];

print("executed .... ".getcwd()." ".$current_exec . " incl:


first check if there are commandline parameters, and parse them. Then check
the includes and parse them. Then output the results prepended with the path
of the executed main script.


Quoted text here. Click to load it

Site Timeline