Skip to content

Commit 299ed4a

Browse files
committed
fix: global logging level
1 parent e868164 commit 299ed4a

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/main/java/io/supertokens/Main.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ private void init() throws IOException, StorageQueryException {
161161

162162
StorageLayer.loadStorageUCL(CLIOptions.get(this).getInstallationPath() + "plugin/");
163163

164-
SAMLBootstrap.initialize();
165-
166164
// loading configs for core from config.yaml file.
167165
try {
168166
Config.loadBaseConfig(this);
@@ -186,6 +184,9 @@ private void init() throws IOException, StorageQueryException {
186184
// init file logging
187185
Logging.initFileLogging(this);
188186

187+
// Required for SAML related stuff
188+
SAMLBootstrap.initialize();
189+
189190
// initialise cron job handler
190191
Cronjobs.init(this);
191192

src/main/java/io/supertokens/config/CoreConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,10 @@ public String getIpDenyRegex() {
494494
return ip_deny_regex;
495495
}
496496

497+
public String getLogLevel() {
498+
return log_level;
499+
}
500+
497501
public Set<LOG_LEVEL> getLogLevels(Main main) {
498502
if (allowedLogLevels != null) {
499503
return allowedLogLevels;

src/main/java/io/supertokens/output/Logging.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package io.supertokens.output;
1818

19+
import ch.qos.logback.classic.Level;
1920
import ch.qos.logback.classic.Logger;
2021
import ch.qos.logback.classic.LoggerContext;
2122
import ch.qos.logback.classic.spi.ILoggingEvent;
@@ -55,6 +56,12 @@ public class Logging extends ResourceDistributor.SingletonResource {
5556
public static final String ANSI_WHITE = "\u001B[37m";
5657

5758
private Logging(Main main) {
59+
// Set global logging level
60+
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
61+
Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
62+
Level newLevel = Level.toLevel(Config.getBaseConfig(main).getLogLevel(), Level.INFO); // Default to INFO if invalid
63+
rootLogger.setLevel(newLevel);
64+
5865
this.infoLogger = Config.getBaseConfig(main).getInfoLogPath(main).equals("null")
5966
? createLoggerForConsole(main, "io.supertokens.Info", LOG_LEVEL.INFO)
6067
: createLoggerForFile(main, Config.getBaseConfig(main).getInfoLogPath(main),

0 commit comments

Comments
 (0)