您登录到数据库,当数据库关闭时您在哪里登录?

问题描述:

我正在使用使用Pear登录PHP ,并且进入了标准问题:当数据库不可用时,可以使用基于文件的日志记录吗?我不介意由于并发问题而导致速度变慢,但是由于多次同时命中,它不会无法正常工作.

I'm working with logging in PHP with Pear, and I get into a standard problem: can I use file-based logging when the DB is not available? I don't mind if it's slow due to concurrency issues, but it cannot fail to work due to multiple, simultaneous hits.

我通常在问这个问题(针对其他Web技术),尤其是针对Pear for PHP.

I'm asking this question in general (for other web technologies) and specifically for Pear for PHP.

谢谢!

通常,如果无法连接到数据库,则登录到文件系统是一个很好的选择.同时点击不成问题(锁定...).如果您已经有适合数据库的日志,那么最简单的方法就是使用sqlite作为后备.

Generally, logging to the file system is a good fall back if you can't connect to your database. Simultaneous hits shouldn't be a problem (locks...). If you already have your logs adapted for a database perhaps the easiest way to go would be to use sqlite as a fall back.

在这种情况下,另一种方式是通过电子邮件发送日志事件,除了不丢失事件外,这种方法还应该使您更快地意识到数据库问题.

Another way would be to email log events in this case, in addition to not loosing them this approach should make you aware of your database problem faster.