|
@@ -1,8 +1,7 @@
|
|
import { transports, createLogger, format } from "winston";
|
|
import { transports, createLogger, format } from "winston";
|
|
-import { ElasticsearchTransport } from 'winston-elasticsearch';
|
|
|
|
-import APM from 'elastic-apm-node'
|
|
|
|
-import { Client } from '@elastic/elasticsearch'
|
|
|
|
-
|
|
|
|
|
|
+import { ElasticsearchTransport } from "winston-elasticsearch";
|
|
|
|
+import APM from "elastic-apm-node";
|
|
|
|
+import { Client } from "@elastic/elasticsearch";
|
|
|
|
|
|
import cluster from "cluster";
|
|
import cluster from "cluster";
|
|
import path from "path";
|
|
import path from "path";
|
|
@@ -34,7 +33,6 @@ const customFormat = format.printf(({ timestamp, level, message, label = "", ...
|
|
// apiKey: 'SDNncElZQUJPcU1OdjVQSFRaY0I6MGpLUWg2TldSS0tTSjdRS0FfZGZGdw=='
|
|
// apiKey: 'SDNncElZQUJPcU1OdjVQSFRaY0I6MGpLUWg2TldSS0tTSjdRS0FfZGZGdw=='
|
|
// })
|
|
// })
|
|
|
|
|
|
-
|
|
|
|
// const esTransportOpts = {
|
|
// const esTransportOpts = {
|
|
// level: 'info',
|
|
// level: 'info',
|
|
// indexPrefix: 'logging-api',
|
|
// indexPrefix: 'logging-api',
|
|
@@ -54,6 +52,8 @@ const customFormat = format.printf(({ timestamp, level, message, label = "", ...
|
|
// }
|
|
// }
|
|
// const esTransport = new ElasticsearchTransport(esTransportOpts);
|
|
// const esTransport = new ElasticsearchTransport(esTransportOpts);
|
|
|
|
|
|
|
|
+const errorLogPath = process.env.LOGGER_PATH ? rocess.env.LOGGER_PATH + "error.log" : join(__dirname, "../../logs/error.log");
|
|
|
|
+const combinedLogPath = process.env.LOGGER_PATH ? rocess.env.LOGGER_PATH + "combined.log" : join(__dirname, "../../logs/combined.log");
|
|
|
|
|
|
const logger = createLogger({
|
|
const logger = createLogger({
|
|
level: "debug",
|
|
level: "debug",
|
|
@@ -69,9 +69,9 @@ const logger = createLogger({
|
|
// - Write all logs with importance level of `info` or less to `combined.log`
|
|
// - Write all logs with importance level of `info` or less to `combined.log`
|
|
//
|
|
//
|
|
new transports.Console(),
|
|
new transports.Console(),
|
|
- new transports.File({ filename: join(__dirname, "../../logs/error.log"), level: "error" }),
|
|
|
|
|
|
+ new transports.File({ filename: errorLogPath, level: "error" }),
|
|
new transports.File({
|
|
new transports.File({
|
|
- filename: join(__dirname, "../../logs/combined.log"),
|
|
|
|
|
|
+ filename: combinedLogPath,
|
|
}),
|
|
}),
|
|
// esTransport
|
|
// esTransport
|
|
],
|
|
],
|