Laravel打印日志

时间:2017-06-14 11:35:03

标签: php laravel laravel-5

我正在尝试在控制台上打印日志:

我导入了:

function trackLocation(e) {
  var rect = videoContainer.getBoundingClientRect(),
      position = ((e.pageX - rect.left) / videoContainer.offsetWidth)*100;
  if (position <= 100) { 
    videoClipper.style.width = position+"%";
    clippedVideo.style.width = ((100/position)*100)+"%";
    clippedVideo.style.zIndex = 3;
    }
}
var videoContainer = document.getElementById("video-compare-container"),
videoClipper = document.getElementById("video-clipper"),
clippedVideo = videoClipper.getElementsByTagName("video")[0];
videoContainer.addEventListener( "mousemove", trackLocation, false); 
videoContainer.addEventListener("touchstart",trackLocation,false);
videoContainer.addEventListener("touchmove",trackLocation,false);

然后在控制器中使用

use Log;

但它没有打印任何日志。

3 个答案:

答案 0 :(得分:3)

我认为您需要在运行后检查storage/logs/laravel.log

Log::info('test log');

希望这有助于你

答案 1 :(得分:1)

您需要配置laravel存储日志的位置。默认Log::info()将日志放在日志文件中,而不是控制台。你可以使用tail -f logpath来查看日志。

答案 2 :(得分:1)

在正常情况下,日志问题与正确的写入权限相关联到日志文件夹(存储/日志)。

如果您正在使用调试/报告库,例如 Bugsnag,,则需要明确指定您需要Laravel日志和Bugsnag日志。要使用Bugsnag启用Laravel日志,请使用multi选项在AppServiceProvider中注册Bugsnag。

public function register() {
    // Bugsnag
    $this->app->alias('bugsnag.multi', \Illuminate\Contracts\Logging\Log::class);
    $this->app->alias('bugsnag.multi', \Psr\Log\LoggerInterface::class);
}