2016-09-21 72 views
0

我想從PhantomJS腳本發送日誌消息給Graylog。有沒有辦法做到這一點?從PhantomJS發送日誌到Graylog2

+0

PhantomJS如何發射日誌?標準出來?進入磁盤上的日誌文件?他們是如何格式化的? – joschi

+0

現在我只有一個Console.log消息。 –

+0

在這種情況下,請查看Graylog Collector Sidecar:http://docs.graylog.org/zh/2.1/pages/collector_sidecar.html – joschi

回答

0

我解決了這種方式:

function remoteLog(message) { 

var page = require('webpage').create(), 
server = 'http://10.68.130.24:12202/gelf', 
data = '{"short_message":"' + message + '", "host":"phantomjs.smediresource.com", "project" : "Dynacare", "facility":"phantomJS", "environment":"QA", "application": "phantomJS", "content": "applicationLog"}'; 

page.open(server, 'post', data, function (status) { 
    if (status !== 'success') { 
     console.error('Unable to post!'); 
    } 
    page.close(); 
}); 

} 

它的工作原理,但產生一些碰撞,由於PhantomJS的內存泄漏。