我想将终端错误写入日志文件 - LUMEN

时间:2015-07-07 06:42:51

标签: php ubuntu laravel lumen

我正在使用LUMEN框架。

我想将所有出现在控制台或终端中的错误记录或写入日志文件。这样我就可以看到这个过程中出现了什么错误。

目前我正在使用此命令运行我的LUMEN服务器:

    let directory: NSURL = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier("group.io.github.brady131313.Deck-of-Death")!
    let realmPath = directory.path!.stringByAppendingPathComponent("db.realm")
    Realm.defaultPath = realmPath

那么如何在日志文件中获取所有这些错误?

我想记录的示例错误:

nohup php artisan queue:work --daemon & ?

2 个答案:

答案 0 :(得分:2)

您可以将输出重定向到这样的文件:

nohup php artisan queue:work --daemon > ./queue_worker.log &

将终端输出保存到一个文件并将错误保存到另一个文件:

nohup php artisan queue:work --daemon > output.log 2> errors.log &

答案 1 :(得分:0)

示例:nohup ruby post_receive.rb >> /root/logPostReceive.log 2>&1 &
2>& 1 将stderr重定向到stdout