Re: shell script - disable log output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Richard Lynch wrote:
I'm writing a shell script that uses error_log function to log some
data, but it echos the error message to the output without logging the
message to the log file.


"the log file"...

*WHAT* log file?

A shell script has no pre-determined log file, really.

Actually, it's almost for sure STDOUT at that point, or maybe STDOUT, but
I doubt it.  If you were coding PHP engine and needed to send error output
somewhere under shell circumstances, you'd think STDOUT would be "it"
right?...

So you can probably re-direct 2 (STDOUT) to somewhere to get the error_log
output where you want it.

I think in most shells that turns into:
test.php 2> /var/log/test
YMMV
It's up to you to figure out re-directs in your shell of choice.  Good luck.

You should probably use can use set_error_handler to trap errors -- though
that will not catch error_log output, I don't think.

You can also use set_error_reporting() to get rid of errors entirely,
though that's not recommended.


I don't really need it to log into a file, but I wanted to prevent it from echoing to the screen.


So I guess there's no way to prevent from error_log() (using defaults) to echo to the screen (STDOUT).
error_reporting() affects on errors produced by PHP itself. I tried to set it to 0 before the call, but it didn't help.
set_error_handler() affects on trigger_error() and not on error_log().


It seems that the extern lib I use should use trigger_error() (or user_error()) function instead, which is the traditional way to report user-defined errors.

Thanks for your help all...

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux