I am dealing with logging in PHP with Pear, and that i enter into a typical problem: can one use file-based logging once the DB isn't available? I do not mind whether it's slow because of concurrency issues, however it cannot fail because of multiple, synchronised hits.

I am asking this generally (for other internet technologies) and particularly for Pear for PHP.

Thanks!

Generally, logging towards the file system is a great fall back if you cannot connect with your database. Synchronised hits should not be considered a problem (locks...). If you have your logs modified for any database possibly the simplest approach to take is always to use sqlite like a fall back.

One other way is always to email log occasions within this situation, additionally not to losing them this method should cause you to conscious of your database problem faster.

You are able to pass a current database object in to the singleton method of Log - without having a database you are able to revert to alternative logging techniques (or traditional user_error())

require_once 'DB.php';
$db = &DB::connect('pgsql://jon@localhost+unix/logs');

$conf['db'] = $db;
$logger = &Log::singleton('sql', 'log_table', 'ident', $conf);