From ce022e41f6fde8d04e9d8e941c40ce8cfdc7d35b Mon Sep 17 00:00:00 2001 From: Yoway Buorn Date: Sun, 23 Jan 2022 13:33:40 +0300 Subject: [PATCH 1/3] writes errors to stderr --- src/main/java/io/supertokens/storage/mysql/ConnectionPool.java | 2 +- src/main/java/io/supertokens/storage/mysql/output/Logging.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/supertokens/storage/mysql/ConnectionPool.java b/src/main/java/io/supertokens/storage/mysql/ConnectionPool.java index 55d0248..75bdf23 100644 --- a/src/main/java/io/supertokens/storage/mysql/ConnectionPool.java +++ b/src/main/java/io/supertokens/storage/mysql/ConnectionPool.java @@ -132,7 +132,7 @@ public static void initPool(Start start) { } if (!longMessagePrinted) { longMessagePrinted = true; - Logging.info(start, errorMessage); + Logging.error(start, errorMessage, true); } double minsRemaining = (maxTryTime - System.currentTimeMillis()) / (1000.0 * 60); NumberFormat formatter = new DecimalFormat("#0.0"); diff --git a/src/main/java/io/supertokens/storage/mysql/output/Logging.java b/src/main/java/io/supertokens/storage/mysql/output/Logging.java index f31cd51..4265e0c 100644 --- a/src/main/java/io/supertokens/storage/mysql/output/Logging.java +++ b/src/main/java/io/supertokens/storage/mysql/output/Logging.java @@ -164,6 +164,9 @@ private Logger createLoggerForConsole(Start start, String name) { logConsoleAppender.setEncoder(ple); logConsoleAppender.setContext(lc); logConsoleAppender.start(); + if (name.startsWith("io.supertokens.storage.mysql.Error")) { + logConsoleAppender.setTarget("System.err"); + } Logger logger = (Logger) LoggerFactory.getLogger(name); logger.addAppender(logConsoleAppender); From 757ab396662a891e721c1814db3ecadd3394b038 Mon Sep 17 00:00:00 2001 From: Yoway Buorn Date: Sun, 23 Jan 2022 13:33:40 +0300 Subject: [PATCH 2/3] writes errors to stderr --- CHANGELOG.md | 4 ++++ .../java/io/supertokens/storage/mysql/ConnectionPool.java | 2 +- .../java/io/supertokens/storage/mysql/output/Logging.java | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 947d02c..2d96a4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixes + +- Run as container, errors are merged into stdout (instead of going to stderr) + ## [1.12.0] - 2022-01-14 ### Added diff --git a/src/main/java/io/supertokens/storage/mysql/ConnectionPool.java b/src/main/java/io/supertokens/storage/mysql/ConnectionPool.java index 55d0248..75bdf23 100644 --- a/src/main/java/io/supertokens/storage/mysql/ConnectionPool.java +++ b/src/main/java/io/supertokens/storage/mysql/ConnectionPool.java @@ -132,7 +132,7 @@ public static void initPool(Start start) { } if (!longMessagePrinted) { longMessagePrinted = true; - Logging.info(start, errorMessage); + Logging.error(start, errorMessage, true); } double minsRemaining = (maxTryTime - System.currentTimeMillis()) / (1000.0 * 60); NumberFormat formatter = new DecimalFormat("#0.0"); diff --git a/src/main/java/io/supertokens/storage/mysql/output/Logging.java b/src/main/java/io/supertokens/storage/mysql/output/Logging.java index f31cd51..4265e0c 100644 --- a/src/main/java/io/supertokens/storage/mysql/output/Logging.java +++ b/src/main/java/io/supertokens/storage/mysql/output/Logging.java @@ -164,6 +164,9 @@ private Logger createLoggerForConsole(Start start, String name) { logConsoleAppender.setEncoder(ple); logConsoleAppender.setContext(lc); logConsoleAppender.start(); + if (name.startsWith("io.supertokens.storage.mysql.Error")) { + logConsoleAppender.setTarget("System.err"); + } Logger logger = (Logger) LoggerFactory.getLogger(name); logger.addAppender(logConsoleAppender); From 49984dc25cd183cf5ab24ce75ef108bec9c782fb Mon Sep 17 00:00:00 2001 From: Yoway Buorn Date: Mon, 24 Jan 2022 11:51:48 +0300 Subject: [PATCH 3/3] send Hikari errors to console as well --- .../io/supertokens/storage/mysql/HikariLoggingAppender.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/supertokens/storage/mysql/HikariLoggingAppender.java b/src/main/java/io/supertokens/storage/mysql/HikariLoggingAppender.java index 06c113a..3012bd6 100644 --- a/src/main/java/io/supertokens/storage/mysql/HikariLoggingAppender.java +++ b/src/main/java/io/supertokens/storage/mysql/HikariLoggingAppender.java @@ -129,7 +129,7 @@ public void setName(String name) { @Override public void doAppend(ILoggingEvent event) throws LogbackException { if (event.getLevel() == Level.ERROR) { - Logging.error(start, event.getFormattedMessage(), false); + Logging.error(start, event.getFormattedMessage(), true); } else if (event.getLevel() == Level.WARN) { Logging.warn(start, event.getFormattedMessage()); } else {