0

I'm developing a new micro-service with php language, and I want that the logging will be sent to efk server.

What logging Framework should I use in my php app?

How can I sent just the app log (no the whole syslog or apache server log)?

Markus
  • 11
  • 3

1 Answers1

0

Have a look at Monolog. It's versatile, is used by some of the big frameworks, and has support for PSR-3. It's extensible and also supports logging to multiple channels (stderr, logfiles, Loggly, etc)

Once installed & configured, you can use it like so:

// Create the logger
$logger = new Logger('my_logger');

/**
* Now add a handler to log to a local file (you could configure a remote logging service
* or DB connection, or anything you've created to extend monolog)
*/
$logger->pushHandler(new StreamHandler(__DIR__.'/my_app.log', Logger::DEBUG));

// You can now use your logger
$logger->info('Some interesting thing happened in my app');
nealio82
  • 2,611
  • 1
  • 17
  • 19