For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > July 2004 > Re: php engine scripts execution logging [solution]









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: php engine scripts execution logging [solution]
karoshi

2004-07-22, 3:56 pm

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
>
>
>
>
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com