2

Cake PHP stores everything under the /app/tmp/logs folder and if you have multiple servers to see what is happening at each you have to check on each server logs folder.

Is there any solution that I can use with cakephp to centralize in one place the logging for Cakephp with the log files being saved and reset in a daily basis.

Mcloide
  • 422
  • 5
  • 16

2 Answers2

1

Cake allows you to set a parameter in the Controller::log() function.

http://book.cakephp.org/view/159/Using-the-log-function

Basically, when you have an error:

$this->log( 'some message describing the error', 'allserverslog' );
// second param can also be LOG_ERROR or LOG_DEBUG, 2 predefined constants that identify the default logging files
Travis Leleu
  • 4,190
  • 2
  • 27
  • 33
  • The problem is that it still saves in the /tmp/logs folder for every server that the application resides (imagine dealing with a load balancer with 10 servers). That would help identify, but how to save in one single location common to all? – Mcloide Jan 03 '11 at 21:01
  • I would guess that you could give it a full file path, rather than a relative one, and it'll save it anywhere on the filesystem that you want. In a load balanced situation, you'll either need a common mounted NFS share, use a different logging mechanism (syslogd supports network logging and can be tied in with PHP), or to log using a database system. Something that allows you to write over the network, in short, is required for a multiserver logging setup. – Travis Leleu Jan 04 '11 at 01:15
  • Actually found a way out. Define a new logger and send the logs to be saved at the database. Creates a huge overhead, but, works. A solution similar to Log4PHP – Mcloide Oct 23 '12 at 21:58
0

Some quick research shows that a clean method would be to redefine the TMP constant (by default define('TMP', APP.'tmp'.DS)) in /app/webroot/index.php to point the whole temp directory someplace else. This is not a good solution if the folder is supposed to be shared though, since different apps may step on each others feet with their temp files.

The only apparent way to point only the log directory someplace else seems to be to edit /cake/config/paths.php.

If your goal is only to make it easy to skim through log files of different apps quickly, you could simply put a bunch of symlinks to those logs into one directory.
Or, the other way around, you can make each /app/tmp/logs folder a symlink to some shared folder. Not sure I'd recommend that though; having different apps write to the same log may get confusing, since you may not always be sure which app a message came from.

deceze
  • 510,633
  • 85
  • 743
  • 889