2015-10-14 58 views
2

我目前bash腳本運行下去:爲什麼沒有永遠的被記錄的錯誤消息

forever -v -l log/system.log -e log/systemerr.log -w --watchIgnore '{log,data,node_modules}' app.js 

我也使用log4js捕獲記錄我的應用程序(具有以下配置):

log4js.configure({ 
    appenders: [ 
    //{ type: 'console' }, 
    { 
     type: "file", 
     absolute: true, 
     filename: "./log/app.log", 
     maxLogSize: 1000000, 
     backups: 10 
    } 
    ]}); 

一切似乎都在這個意義上,我的應用程序的輸出被擺出來app.log,永遠是工作的-l輸出將SYSTEM.LOG:

warn: --minUptime not set. Defaulting to: 1000ms 
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms 

但下面去安慰,我會想到它會去systemerr.log:

error: Could not read .foreverignore file. 
error: ENOENT, open '/home/blah/blah/.foreverignore' 
error: Forever detected script exited with code: 1 
error: Script restart attempt #1 

我怎樣才能得到這個錯誤信息,我認爲這是永遠的產生,到systemerr.log?

+0

對於將來的讀者:雖然我能夠通過使用STDERR重定向獲得解決方法,但爲什麼消息/錯誤未被捕獲爲永遠的-l選項的一部分,這個問題沒有被討論(或回答)。 – HiDefLoLife

回答

0

永遠-e ERRFILE選項需要:

日誌從孩子腳本錯誤輸出到ERRFILE由永遠本身不會記錄在這裏生產

錯誤,這是偉大的你只能在這裏得到你的應用程序產生的錯誤。

如果你真的想在文件中使用IO redirection永遠誤差爲STDERR在你的包裹bash腳本是這樣的:

forever ... 2>> forever-errors.log 

如果你仍然想爲某些原因讓在同這些錯誤文件作爲您的應用程序錯誤日誌,您可能會重定向並將STDERR附加到與錯誤日誌相同的文件。

+0

我用你的答案爲我的bash腳本創建了一個catch-all system.log文件。我的bash腳本中的所有錯誤以及永遠運行(我的bash腳本中的最後一條命令)所產生的錯誤都會被捕獲(即2> system.log)謝謝! – HiDefLoLife

相關問題