1

all,

My log4php gets this error in a new server environment.

PHP Warning: log4php: [LoggerAppenderPDO:default]: Failed connecting to database. Closing appender. Error: could not find driver in ../log4php/LoggerAppender.php on line 283

I have the same settings for log4php (1. config.xml file 2.same log4php version) as my local development, which works perfectly. I tried simply log to a file in the new server, it works, which means the log4php lib has no problem. And I can even log to the database in the new server from my local script using local log4php lib, which means my server can recognize log4php logging.

I think this should related to the authentication to the database from the server itself. But have no idea what is the problem and how to solve it. Any idea?

Work around:

After some searches and tests(script using PDO not mysqli to connect to the database,reference here) , I confirm the problem is caused by lacking of pdo_mysql related driver, as akluth pointed out. I tried to re-install php5-mysql, but it failed, I tried to modify php.ini, got more errors. I think that is because the mysql-cluster settings maybe different from normal mysql. As the new server is a production server, we decide not to touch it and move the scripts to other server with normal mysql settings.

zhihong
  • 1,808
  • 2
  • 24
  • 34
  • Make sure you have the `PDO` extension enabled on the new server. Look out for `extension=pdo_*.sql` in the php.ini file where * stands for either mysql, sqlite or any other database system you're using. – akluth Oct 16 '13 at 11:56
  • @akluth, there is no such "extension" line in my php.ini, also no this line in the php.ini file in my local development, which log4php works perfectly. I am wondering whether this can be related to the php version? I find the php versions are different in the server and my local development. – zhihong Oct 16 '13 at 12:20
  • It'd help if you post the PHP versions you're using in your question as well as the server you're using; it's quite hard to fix an environment when you barely know something about it. – akluth Oct 16 '13 at 12:32
  • @akluth, my server version of php is 5.3.6-13ubuntu3.10, in development is 5.3.10-1ubuntu3.8, and I am wondering, the file you mentioned is pdo_*.so or pdo_*.sql? – zhihong Oct 16 '13 at 12:40
  • @akluth are you using a MySQL database? – KarlosFontana Oct 16 '13 at 13:07
  • @KarlosFontana, I am using MYSQL-CLUSTER database, in Ubuntu 12.04 – zhihong Oct 16 '13 at 13:30
  • Just try adding this line somewhere under the [extension] part in the php.ini: `extension=pdo_mysql.so`. It is `.so`, ***not*** `.sql`. Then restart the webserver or reload the webservers configuration. – akluth Oct 16 '13 at 13:59
  • After add the pdo_mysql.so, and run the php script, I got an new error: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/pdo_mysql.so' - /usr/lib/php5/20090626/pdo_mysql.so: undefined symbol: php_pdo_register_driver in Unknown on line 0 – zhihong Oct 16 '13 at 14:22

0 Answers0