Well, using the word "awesome" in three out of four posts here is rather commonplace, but lately I have been in need of a simple to set up and use debugging tool, and being a refugee from j2ee, I have always missed some kind of logging facility… so, imagine my joy when lo and behold I read this morning, about the … great… log4drupal – a logging api for drupal.
First off, I join the chorus of voices gently chidding the fact that this is not hosted on http://drupal.org, since it will be very useful for developers. But it is just what I need right now, so I can’t be too grumpy.
The README.txt file explains that the PEAR Log package needs to be installed on the system first, so I downloaded the latest stable version from http://pear.php.net/package/Log as suggested. I ran a php info call (from the devel package right inside drupal) to find out quickly where my include_path was on my development box (Ubuntu). It said:
So since PEAR installation is broken on my system right now and I don’t use it that often so as to find the time to fix it, I just shoved the package in the /usr/share/pear directory, thusly:
/usr/share/pear# ls -l total 32 drwxr-xr-x 2 root root 4096 2007-11-13 14:14 Log -rw-rw-rw- 1 root root 25202 2007-05-14 03:45 Log.php /usr/share/pear#
I then installed the module in the usual way, and headed over to to Administer > Log4Drupal to setup things as shown in the article (see first paragraph).
The main thing is to specify a path that a) exists, and b) can be written to by the apache server user (on my box "www-data".
For quickness on my system, I created the default directory, /var/log/drupal and proceeded as follows:
victorkane@mentor:/var/log$ sudo mkdir drupal victorkane@mentor:/var/log$ cd drupal victorkane@mentor:/var/log/drupal$ sudo > drupal.log bash: drupal.log: Permission denied victorkane@mentor:/var/log/drupal$ sudo cat '' > drupal.log bash: drupal.log: Permission denied victorkane@mentor:/var/log/drupal$ sudo vi drupal.log victorkane@mentor:/var/log/drupal$ sudo chown www-data drupal.log
I then put the following code into a devel module execute php box:
$name = 'awebfactory'; log_debug("Hello, $name");
:/var/log/drupal$ cat drupal.log
[14:53:06 11/13/07] [debug] [/home/victorkane/work/AWebFactory/Steinhardt/steinhardtsa/work/empleos/sites/all/modules/devel/devel.module(641) : eval()’d code:2] Hello, awebfactory