无法将logging插入到Bluemix中的PostgreSQL中

我尝试在Bluemix平台中使用Node.js来运行postgresql。 但是,有一个问题。 我尝试使用https://www.ng.bluemix.net/docs/#starters/nodejs/index.html#PostgreSQL中描述的代码。

我可以运行我在本地环境中成功编写的应用程序。 但是,它在Bluemix平台中无法正常运行。

以下是描述我所做的代码:

var recordVisit = function(req, res) { /* Connect to the DB and auth */ pg.connect(psql, function(err, client, done) { if (err) { return console.error('Error requesting client', err); } console.log(req.ip); client.query('insert into ips(ip, ts) values($1, $2)', [req.ip, new Date()], function(err, result) { if (err) { done(); return console.error('Error inserting ip', err); } client.query('select count(ip) as count from ips where ip=$1', [req.ip], function(err, result) { done(); if (err) { return console.error('Error querying count', err); } console.log("You have visited " + result.rows[0].count + " times") // res.writeHead(200, {'Content-Type': 'text/html'}); // res.end(); } ); } ); } ); }; 

它是从bluemix文件中的代码。 Bluemix访问计数的结果总是为零(0)。 但在当地环境的结果是可以的。 而且我没有从Bluemix平台得到任何错误。 所以我假设可以插入访问logging。 但是,似乎不是。

任何人都可以有任何指针来解决这个问题吗?

我试图插入更多的日志到插入function。 我发现在Bluemix平台的INSERT SQL的结果中variablesreq.ip变得不确定。

所以我添加了一个局部variables来存储请求的IP,以保持内容。