Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Logging class instance
  • Hi

    Is there any particular reason for not allowing logger class having multiple instances? It's being initialized with 'fuelphp' instance by default.

    I would like to log to a custom file under some circumstances (eg. log actions being made within admin panel to a separated file or directory), but this will require me having another logger instance.

    Monolog looks to be very powerful, however without multiple instances it's one-dimensional tool. 
  • HarroHarro
    Accepted Answer
    The Log class is only intended for internal Fuel logging. It was never designed to serve other purposes, none of the other log functions support an instance either.

    You can easily do:

    $mylog = new \Monolog\Logger('mylog');

    and do whatever you want with it if you have a special requirement.
  • Working with the \Monolog\Logger will require us to setup a handler each time and so on. Fuel logging class already do that. So it's possible to extend the logging class to easly do:

    $log = Log::forge('customlogs/test');
    $log->error_('Something bad happened');


  • Please make an issue for this feature request at https://github.com/fuel/core/issues

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion