13

Ok I've tried searching all over but can't seem to get just a simple straight forward answer.

I want to write log messages (INFO, ERROR, etc.) to the Kohana log file /application/logs/YYYY/MM/DD.php.

How do I do it?

Teun Zengerink
  • 4,277
  • 5
  • 30
  • 32
krische
  • 1,010
  • 3
  • 11
  • 17

2 Answers2

18

Try the log class add() method: http://kohanaframework.org/3.2/guide/api/Log#add

Call it like this:

Log::instance()->add(Log::NOTICE, 'My Logged Message Here');

For the first parameter (level) use one of the 9 constants defined in the log class

Dickie
  • 597
  • 5
  • 8
  • 1
    That worked! Although I also had to add a line to make it write out to the file as well. `Log::instance()->write();` – krische Oct 21 '11 at 13:16
  • 2
    enable log writing when adding to log by specifying Log::$write_on_add=TRUE in your bootstrap file – yretuta Feb 07 '12 at 01:44
2

Shuadoc you shouldn't touch system files (all those under system folder). Change the value in bootstrap.php instead as stated by Ygam

Otherwise, when updates come you'll be in trouble.

Gustavo
  • 21
  • 1