But why should I? You want to know... ● What happened? ● When did it happen? ● Where did it happen? (and where didn't it?) ● Which steps were taken? ● And sometimes, actual input and output
Okay, but how do I do this then? ● Inspiration: log4j (java) ○ PHP: log4php ○ Python: logging (In standard library!) ○ Ruby: log4r, logging include('Logger.php'); $logger = Logger::getLogger("main"); $logger->info("This is an informational message."); $logger->warn("I'm not feeling so good..."); INFO - This is an informational message. WARN - I'm not feeling so good...
Tips, tricks & pitfalls ● Use the various levels effectively ○ (WARN == INFO) == False ● Debugging should be OFF on production ● Be careful with big objects or method calls ○ $logger->debug("Doing something with object " . $this->nastyLongObjectLookup()); // *yawn* App hangs