Re: shell script - disable log output

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

 



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

> Code I use (php5 on unix):
> *********************************************
> #!/usr/local/php/bin/php -q
> <?php
> error_log("My error message");
> ?>
> *********************************************
> OUTPUT:
> $ test.php
> My error message
> $
>
> How can I prevent the error messages from being echoed to the client?

-- 
Like Music?
http://l-i-e.com/artists.htm

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