%level_name% > %message% %context% %extra%\n"; // finally, create a formatter $formatter = new LineFormatter($output, $dateFormat); // create a log channel try { $stream = new StreamHandler($path, Logger::INFO); $stream->setFormatter($formatter); } catch (Exception $e) { error_log("init Monolog Stream config error"); } return $stream; } function getLogger() { $log = new Logger('name'); $log->pushHandler(getStream(__ROOT__ . "/log/run.log")); $log->pushHandler(getStream("php://stdout")); // <<< uses a stream return $log; } function info($msg) { getLogger()->info($msg); } function error($msg) { getLogger()->error($msg); }