From 991620468db2e4fb2e2e879edf11fb80c554581a Mon Sep 17 00:00:00 2001 From: Alexey Bannov Date: Tue, 8 Nov 2022 15:37:52 +0300 Subject: [PATCH] change format logs for CloudWatch --- common/ASC.Socket.IO/app/log.js | 10 ++++------ common/ASC.Socket.IO/config/config.json | 4 ++-- common/ASC.SsoAuth/app.js | 10 ++++------ common/ASC.SsoAuth/config/config.json | 4 ++-- common/ASC.UrlShortener/app/log.js | 10 ++++------ common/ASC.UrlShortener/config/config.json | 4 ++-- common/ASC.WebDav/helper/logger.js | 10 ++++------ common/ASC.WebDav/server/config.js | 4 ++-- common/ASC.WebPlugins/config/config.json | 4 ++-- common/ASC.WebPlugins/src/log.ts | 12 +++++------- config/nlog.config | 6 ++++-- 11 files changed, 35 insertions(+), 43 deletions(-) diff --git a/common/ASC.Socket.IO/app/log.js b/common/ASC.Socket.IO/app/log.js index 1740ae614a..251c146b6c 100644 --- a/common/ASC.Socket.IO/app/log.js +++ b/common/ASC.Socket.IO/app/log.js @@ -54,17 +54,15 @@ var options = { cloudWatch: { name: 'aws', level: "debug", - logGroupName: () => { - const hostname = os.hostname(); - - return logGroupName.replace("${instance-id}", hostname); - }, logStreamName: () => { + const hostname = os.hostname(); const now = new Date(); const guid = randomUUID(); const dateAsString = date.format(now, 'YYYY/MM/DDTHH.mm.ss'); - return logStreamName.replace("${guid}", guid) + return logStreamName.replace("${hostname}", hostname) + .replace("${applicationContext}", "SocketIO") + .replace("${guid}", guid) .replace("${date}", dateAsString); }, awsRegion: awsRegion, diff --git a/common/ASC.Socket.IO/config/config.json b/common/ASC.Socket.IO/config/config.json index 9e506228e7..1c81876e59 100644 --- a/common/ASC.Socket.IO/config/config.json +++ b/common/ASC.Socket.IO/config/config.json @@ -8,7 +8,7 @@ "accessKeyId": "", "secretAccessKey": "", "region": "", - "logGroupName": "/docspace/ASC.SocketIO/instances/${instance-id}/general", - "logStreamName": "${guid} - ${date}" + "logGroupName": "/asc/docspace/cluster/cluster_name/general", + "logStreamName": "${hostname} - ${applicationContext} - ${date} - ${guid}" } } diff --git a/common/ASC.SsoAuth/app.js b/common/ASC.SsoAuth/app.js index 9af23ca30d..6cae1704f6 100644 --- a/common/ASC.SsoAuth/app.js +++ b/common/ASC.SsoAuth/app.js @@ -77,17 +77,15 @@ if (aws != null && aws.accessKeyId !== '') transports.push(new WinstonCloudWatch({ name: 'aws', level: "debug", - logGroupName: () => { - const hostname = os.hostname(); - - return logGroupName.replace("${instance-id}", hostname); - }, logStreamName: () => { + const hostname = os.hostname(); const now = new Date(); const guid = randomUUID(); const dateAsString = date.format(now, 'YYYY/MM/DDTHH.mm.ss'); - return logStreamName.replace("${guid}", guid) + return logStreamName.replace("${hostname}", hostname) + .replace("${applicationContext}", "SsoAuth") + .replace("${guid}", guid) .replace("${date}", dateAsString); }, awsRegion: awsRegion, diff --git a/common/ASC.SsoAuth/config/config.json b/common/ASC.SsoAuth/config/config.json index 0e52fbcf80..e969ef751f 100644 --- a/common/ASC.SsoAuth/config/config.json +++ b/common/ASC.SsoAuth/config/config.json @@ -68,7 +68,7 @@ "accessKeyId": "", "secretAccessKey": "", "region": "", - "logGroupName": "/docspace/ASC.SsoAuth/instances/${instance-id}/general", - "logStreamName": "${guid} - ${date}" + "logGroupName": "/asc/docspace/cluster/cluster_name/general", + "logStreamName": "${hostname} - ${applicationContext} - ${date} - ${guid}" } } \ No newline at end of file diff --git a/common/ASC.UrlShortener/app/log.js b/common/ASC.UrlShortener/app/log.js index 3712f417cb..d0fdb6093f 100644 --- a/common/ASC.UrlShortener/app/log.js +++ b/common/ASC.UrlShortener/app/log.js @@ -54,17 +54,15 @@ var options = { cloudWatch: { name: 'aws', level: "debug", - logGroupName: () => { - const hostname = os.hostname(); - - return logGroupName.replace("${instance-id}", hostname); - }, logStreamName: () => { + const hostname = os.hostname(); const now = new Date(); const guid = randomUUID(); const dateAsString = date.format(now, 'YYYY/MM/DDTHH.mm.ss'); - return logStreamName.replace("${guid}", guid) + return logStreamName.replace("${hostname}", hostname) + .replace("${applicationContext}", "UrlShortener") + .replace("${guid}", guid) .replace("${date}", dateAsString); }, awsRegion: awsRegion, diff --git a/common/ASC.UrlShortener/config/config.json b/common/ASC.UrlShortener/config/config.json index 55b1b3c764..992264a4bf 100644 --- a/common/ASC.UrlShortener/config/config.json +++ b/common/ASC.UrlShortener/config/config.json @@ -8,7 +8,7 @@ "accessKeyId": "", "secretAccessKey": "", "region": "", - "logGroupName": "/docspace/ASC.UrlShortener/instances/${instance-id}/general", - "logStreamName": "${guid} - ${date}" + "logGroupName": "/asc/docspace/cluster/cluster_name/general", + "logStreamName": "${hostname} - ${applicationContext} - ${date} - ${guid}" } } \ No newline at end of file diff --git a/common/ASC.WebDav/helper/logger.js b/common/ASC.WebDav/helper/logger.js index e64634de11..41718a9469 100644 --- a/common/ASC.WebDav/helper/logger.js +++ b/common/ASC.WebDav/helper/logger.js @@ -64,17 +64,15 @@ if (aws != null && aws.accessKeyId !== '') transports.push(new WinstonCloudWatch({ name: 'aws', level: "debug", - logGroupName: () => { - const hostname = os.hostname(); - - return logGroupName.replace("${instance-id}", hostname); - }, logStreamName: () => { + const hostname = os.hostname(); const now = new Date(); const guid = randomUUID(); const dateAsString = date.format(now, 'YYYY/MM/DDTHH.mm.ss'); - return logStreamName.replace("${guid}", guid) + return logStreamName.replace("${hostname}", hostname) + .replace("${applicationContext}", "WebDav") + .replace("${guid}", guid) .replace("${date}", dateAsString); }, awsRegion: awsRegion, diff --git a/common/ASC.WebDav/server/config.js b/common/ASC.WebDav/server/config.js index 4cfa95d6a1..04e35100cf 100644 --- a/common/ASC.WebDav/server/config.js +++ b/common/ASC.WebDav/server/config.js @@ -57,8 +57,8 @@ module.exports = { "accessKeyId": "", "secretAccessKey": "", "region": "", - "logGroupName": "/docspace/ASC.WebDav/instances/${instance-id}/general", - "logStreamName": "${guid} - ${date}" + "logGroupName": "/asc/docspace/cluster/cluster_name/general", + "logStreamName": "${hostname} - ${applicationContext} - ${date} - ${guid}" }, method: { diff --git a/common/ASC.WebPlugins/config/config.json b/common/ASC.WebPlugins/config/config.json index b0b910a60d..c9d2e3e1cc 100644 --- a/common/ASC.WebPlugins/config/config.json +++ b/common/ASC.WebPlugins/config/config.json @@ -8,7 +8,7 @@ "accessKeyId": "", "secretAccessKey": "", "region": "", - "logGroupName": "/docspace/ASC.WebPlugins/instances/${instance-id}/general", - "logStreamName": "${guid} - ${date}" + "logGroupName": "/asc/docspace/cluster/cluster_name/general", + "logStreamName": "${hostname} - ${applicationContext} - ${date} - ${guid}" } } diff --git a/common/ASC.WebPlugins/src/log.ts b/common/ASC.WebPlugins/src/log.ts index 172e2ed968..9922473eb6 100644 --- a/common/ASC.WebPlugins/src/log.ts +++ b/common/ASC.WebPlugins/src/log.ts @@ -54,17 +54,15 @@ const options = { cloudWatch: { name: 'aws', level: "debug", - logGroupName: () => { - const hostname = os.hostname(); - - return logGroupName.replace("${instance-id}", hostname); - }, logStreamName: () => { + const hostname = os.hostname(); const now = new Date(); const guid = randomUUID(); const dateAsString = date.format(now, 'YYYY/MM/DDTHH.mm.ss'); - return logStreamName.replace("${guid}", guid) + return logStreamName.replace("${hostname}", hostname) + .replace("${applicationContext}", "WebPlugins") + .replace("${guid}", guid) .replace("${date}", dateAsString); }, awsRegion: awsRegion, @@ -92,7 +90,7 @@ const customFormat = winston.format(info => { const now = new Date(); info.date = date.format(now, 'YYYY-MM-DD HH:mm:ss'); - info.applicationContext = "ASC.WebPlugins"; + info.applicationContext = "WebPlugins"; info.level = info.level.toUpperCase(); const hostname = os.hostname(); diff --git a/config/nlog.config b/config/nlog.config index f6c1c230e5..2008d880cd 100644 --- a/config/nlog.config +++ b/config/nlog.config @@ -17,10 +17,11 @@ - + + @@ -28,9 +29,10 @@ - + +