This is a discussion on php engine scripts execution logging within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hello, I want to gain insight into the access and running of scripts by the php engine on my production ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello,
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 scriptfile. Is there a way to instruct the php engine to log the execution of scriptfiles? Cheers Karoshi |
|
|||
|
karoshi wrote:
> Is there a way to instruct the php engine to log the execution of > scriptfiles? You can use a fake. Rename the php engine and create a shell script named php in the same location of the original php engine that log the script executed (ie. begin and end) and call the original php engine. -- I am what I am, I do what I can L'uomo, conscio di sbagliare, persevera. |
|
|||
|
Hello,
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 : <begin>... $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: ".$current_incl); ....<end> 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. Cheers Karoshi ---------------------------------------------------------------------------- ---------------- "karoshi" <karoshi@japan.com> wrote in message news:cdlnuo$81n$1@reader13.wxs.nl... > Hello, > > 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 > scriptfile. > > Is there a way to instruct the php engine to log the execution of > scriptfiles? > > Cheers > Karoshi > > > > > > |