NYCPHP Meetup

NYPHP.org

[nycphp-talk] Logging best practices

Federico Ulfo rainelemental at gmail.com
Tue May 6 09:39:08 EDT 2014


Hi PHPers,

long time no see, at my current job we recently decided to unify the way we
log cross repos and cross languages, our legacy code for logging is pretty
diverse, we use different functions to log, some uses error_log other
writes straight to file other to scribe, and many mix all the above. This
is relatively good, because we don't miss a beat, everything is logged, the
bad part is that our disk space is often an issue, so on top of log rotate
we've to move the logs on backups, which are sparse as well.

Scribe is pretty cool, because it store everything in one place, which then
we move somewhere else to save disk space, again!

We're considering to use syslog as common logging for all languages, mostly
PHP, Java and Python (Scala, Perl, Ruby ...), so we can finally log with a
standard format, e.g.:
TIME - HOSTNAME PID [LOG LEVEL] MESSAGE

For PHP we'll probably use Monolog, someone suggested to use it wrapped
into helper functions such as sail_info(), sail_debug(), sail_error(),
sail_warn(), I'm personally skeptical for this solution because not too
maintainable, but I agree that Monolog is too verbose and quite ugly to
remember.

What's your experience with logging? Is there anything that you could
suggesting to do and (especially) not to do when organizing the logs?

I'll be happy to hear any of your comments.

Thanks,
Federico.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20140506/bdb0719f/attachment.html>


More information about the talk mailing list