fluent / fluent-logger-php

A structured logger for Fluentd (PHP)
Other
215 stars 57 forks source link

Monolog and/or PSR-3 #20

Closed aktau closed 11 years ago

aktau commented 11 years ago

Hey guys! In the spirit of being able to integrate this with my project already using Monolog and handing out PSR-3 LoggerInterface's, don't you think it would be cool to add a fluentd handler for those things?

chobie commented 11 years ago

@Aktau Thanks spotting it. following standard is a good way. I'll check it in this weekend.

aktau commented 11 years ago

@chobie Thanks! It would be nice if you could investigate. Monolog is definitely one of the most used logging frameworks in the (modern) PHP world, and it already implements PSR-3. Usually I'm not a fan for too much standardization because it can grow mediocre solutions, but in the world of logging I think standardizations is absolutely a good thing. It means being able to swap backends easily, which is all I really care about with logging.

chobie commented 11 years ago

https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md

I saw PSR-3 logger interface documentation. PSR-3 logger uses RFC 5424 log levels but usually we don't use that levels with fluentd.

let's assume the use case like this.

story: logging user error which user does not have right permission.

usage:
$psr3_fluent_logger->emergency("user", array("user_id" => 12345, "error_code" => ($permission_denied = 1));

output:
2013-05-28 emergency.user {user_id: 12345, error_code: 1}

Admitting that use case makes sense with fluentd. but it dose not make sense with other logger I think. We can provide PSR-3 logger interface but I don't think this is good way. Developers are able to switch log backends if we provide PSR-3 logger. but I don't think they want to collect messy logs.

Currently, there are several semistructured log collector: fluentd, scribed, flume...etc. Those users have some objective to analyze corrected log data. Not to put too fine a point on it. syslog style log message is just put log data. there is nothing more or less.

Anyway, I do not provide PSR-3 style logger at this time. I'll work when fig accepted PSR-N semistructured logger.