diff --git a/packages/backend-core/src/environment.ts b/packages/backend-core/src/environment.ts index 971c5941ff..5a230f6925 100644 --- a/packages/backend-core/src/environment.ts +++ b/packages/backend-core/src/environment.ts @@ -75,7 +75,7 @@ function getPackageJsonFields(): { const parsedContent = JSON.parse(content) return { VERSION: parsedContent.version, - SERVICE_NAME: parsedContent.name.replace(/@budibase\//, ""), + SERVICE_NAME: parsedContent.name, } } catch { // throwing an error here is confusing/causes backend-core to be hard to import @@ -168,6 +168,7 @@ const environment = { // @ts-ignore environment[key] = value }, + ROLLING_LOG_MAX_SIZE: process.env.ROLLING_LOG_MAX_SIZE || "100M", } // clean up any environment variable edge cases diff --git a/packages/backend-core/src/logging/pino/logger.ts b/packages/backend-core/src/logging/pino/logger.ts index 7c35dbeff5..e2e6067bbe 100644 --- a/packages/backend-core/src/logging/pino/logger.ts +++ b/packages/backend-core/src/logging/pino/logger.ts @@ -24,7 +24,9 @@ if (!env.DISABLE_PINO_LOGGER) { return { level: label.toUpperCase() } }, bindings: () => { - return {} + return { + service: env.SERVICE_NAME, + } }, }, timestamp: () => `,"timestamp":"${new Date(Date.now()).toISOString()}"`, @@ -36,8 +38,7 @@ if (!env.DISABLE_PINO_LOGGER) { destinations.push(pinoPretty({ singleLine: true })) } - // TODO - if (true) { + if (env.SELF_HOSTED) { destinations.push(localFileDestination()) } @@ -71,9 +72,9 @@ if (!env.DISABLE_PINO_LOGGER) { } function localFileDestination() { - const fileName = path.join(budibaseTempDir(), "logs", `budibase.logs`) + const fileName = path.join(budibaseTempDir(), `budibase.logs`) const outFile = rfs.createStream(fileName, { - size: "10M", + size: env.ROLLING_LOG_MAX_SIZE, teeToStdout: true, })