Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
【Question】Regarding Log class
  • Hello there,

    I just recognised that if the batch is running over the days, Log dose not write correct log file.

    For example, when the batch run from 1st of Jan 2018 until 3d of Jan 2018, all logs went to /2018/01/01.php.

    Is that technically common?

    Regards,
  • HarroHarro
    Accepted Answer
    There is no functionality to rotate the logfile name, it is determined when the log class loaded.

    We generally use separate log files for tasks like that, so you get a log file per task run, instead of per day.

    To do so, at the top of the run() method in your task:

    // Switch to a custom logfile
    $filename = date('c').DS.'-this-task-name.php';
    \Config::set('log_file', $filename);
    \Config::set('log_threshold', \Fuel::L_INFO);

    // Reinitialize the log class
    \Log::initialize();

    logger(\Fuel::L_INFO, 'START - "this name" background task');

  • Thanks for your help.
    I always appreciate it :)

Howdy, Stranger!

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

In this Discussion