我正在使用 @google-cloud/logging-bunyan (^1.2.3) 库和 bunyan (^1.8.12) 来生成一些日志,这些日志将使用接收器保存到 bigquery。我想传递 logName 属性,因为它用于创建表(表名)。我这样做是因为我想为同一个后端(nodeJS 8.16.1)拥有多个表。我使用应用程序引擎进行了测试,它运行良好,但在将其部署到 GKE 集群后,它没有打印指定的 logName。这是我部署的代码片段,可以给你一个想法:
import bunyan from 'bunyan';
import { LoggingBunyan } from '@google-cloud/logging-bunyan';
const loggingBunyan = new LoggingBunyan({
logName: 'driver-status-location', // table name
});
export const driverLocationStatusLogger = bunyan.createLogger({
name: 'yassir-backend-main-log',
streams: [
// Log to the console at 'info' and above
{ stream: process.stdout, level: 'info' },
// And log to Stackdriver Logging, logging at 'info' and above
loggingBunyan.stream('info'),
],
});
export const customDriverLocationStatusLogger = (action, metadata) =>{
driverLocationStatusLogger.info({ labels: { action }, metadata});
}
这是我得到的日志格式:
{
insertId: "hecxukciyeulfqocw"
jsonPayload: {…}
labels: {…}
logName: "projects/xxx-xx-xx/logs/stdout"
receiveTimestamp: "2019-10-10T09:10:16.034265465Z"
resource: {…}
severity: "INFO"
timestamp: "2019-10-10T09:10:15.292Z"
}
如您所见, logName 不是我指定的。你认为问题是什么?