ch.qos.logback.classic.LoggerContext Java Examples
The following examples show how to use
ch.qos.logback.classic.LoggerContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DiagnosticLogger.java From synopsys-detect with Apache License 2.0 | 7 votes |
private FileAppender<ILoggingEvent> addAppender(final String file) { final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); final PatternLayoutEncoder ple = new PatternLayoutEncoder(); ple.setPattern("%date %level [%file:%line] %msg%n"); ple.setContext(lc); ple.start(); final FileAppender<ILoggingEvent> appender; appender = new FileAppender<>(); appender.setFile(file); appender.setEncoder(ple); appender.setContext(lc); final ThresholdFilter levelFilter = new ThresholdFilter(); levelFilter.setLevel(this.level.levelStr); levelFilter.start(); appender.addFilter(levelFilter); appender.start(); final ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); logbackLogger.addAppender(appender); return appender; }
Example #2
Source File: GelfEncoderTest.java From logback-gelf with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void simple() throws IOException { encoder.start(); final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); final Logger logger = lc.getLogger(LOGGER_NAME); final String logMsg = encodeToStr(simpleLoggingEvent(logger, null)); final ObjectMapper om = new ObjectMapper(); final JsonNode jsonNode = om.readTree(logMsg); basicValidation(jsonNode); final LineReader msg = new LineReader(new StringReader(jsonNode.get("full_message").textValue())); assertEquals("message 1", msg.readLine()); }
Example #3
Source File: LoggingConfiguration.java From okta-jhipster-microservices-oauth-example with Apache License 2.0 | 6 votes |
private void setMetricsMarkerLogbackFilter(LoggerContext context) { log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME); OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator(); onMarkerMetricsEvaluator.setContext(context); onMarkerMetricsEvaluator.addMarker("metrics"); onMarkerMetricsEvaluator.start(); EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>(); metricsFilter.setContext(context); metricsFilter.setEvaluator(onMarkerMetricsEvaluator); metricsFilter.setOnMatch(FilterReply.DENY); metricsFilter.start(); for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) { for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) { Appender<ILoggingEvent> appender = it.next(); if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) { log.debug("Filter metrics logs from the {} appender", appender.getName()); appender.setContext(context); appender.addFilter(metricsFilter); appender.start(); } } } }
Example #4
Source File: LoggingConfigurator.java From logging-java with Apache License 2.0 | 6 votes |
/** * Add a sentry appender. * @param dsn the sentry dsn to use (as produced by the sentry webinterface). * @param logLevelThreshold the threshold for log events to be sent to sentry. * @return the configured sentry appender. */ public static SentryAppender addSentryAppender(final String dsn, Level logLevelThreshold) { final Logger rootLogger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); final LoggerContext context = rootLogger.getLoggerContext(); SentryAppender appender = new SentryAppender(); appender.setDsn(dsn); appender.setContext(context); ThresholdFilter levelFilter = new ThresholdFilter(); levelFilter.setLevel(logLevelThreshold.logbackLevel.toString()); levelFilter.start(); appender.addFilter(levelFilter); appender.start(); rootLogger.addAppender(appender); return appender; }
Example #5
Source File: Syslog4jAppenderTest.java From logback-syslog4j with MIT License | 6 votes |
public void testUdpSender() throws JoranException, InterruptedException { LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(context); context.reset(); configurator.doConfigure(this.getClass().getClassLoader().getResourceAsStream("logback-syslog4j-udp.xml")); Logger logger = context.getLogger("test-udp"); logger.info("test message over udp"); context.stop(); Thread.sleep(100); final String serverData = serverStream.toString(); assertTrue("Server received: " + serverData, serverData.contains("test message over udp")); }
Example #6
Source File: KonkerStaticLoggerBinder.java From konker-platform with Apache License 2.0 | 6 votes |
void init() { try { try { (new KonkerContextInitializer(this.defaultLoggerContext)).autoConfig(); } catch (JoranException var2) { Util.report("Failed to auto configure default logger context", var2); } if(!StatusUtil.contextHasStatusListener(this.defaultLoggerContext)) { StatusPrinter.printInCaseOfErrorsOrWarnings(this.defaultLoggerContext); } this.contextSelectorBinder.init(this.defaultLoggerContext, KEY); this.initialized = true; } catch (Throwable var3) { Util.report("Failed to instantiate [" + LoggerContext.class.getName() + ']', var3); } }
Example #7
Source File: SentryConfiguration.java From Lavalink with MIT License | 6 votes |
private static synchronized SentryAppender getSentryLogbackAppender() { LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); ch.qos.logback.classic.Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); SentryAppender sentryAppender = (SentryAppender) root.getAppender(SENTRY_APPENDER_NAME); if (sentryAppender == null) { sentryAppender = new SentryAppender(); sentryAppender.setName(SENTRY_APPENDER_NAME); ThresholdFilter warningsOrAboveFilter = new ThresholdFilter(); warningsOrAboveFilter.setLevel(Level.WARN.levelStr); warningsOrAboveFilter.start(); sentryAppender.addFilter(warningsOrAboveFilter); sentryAppender.setContext(loggerContext); root.addAppender(sentryAppender); } return sentryAppender; }
Example #8
Source File: LogbackLoggingConfigurer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private void doFailSafeConfiguration() { // Not really fail-safe, just less likely to fail final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); context.reset(); Logger rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME); rootLogger.setLevel(Level.INFO); ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>(); rootLogger.addAppender(appender); appender.setContext(context); appender.setTarget("System.err"); PatternLayout layout = new PatternLayout(); appender.setLayout(layout); layout.setPattern("%msg%n%ex"); layout.setContext(context); layout.start(); appender.start(); }
Example #9
Source File: GelfEncoderTest.java From logback-gelf with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void customThreadNameKey() throws IOException { encoder.setThreadNameKey("Thread"); encoder.start(); final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); final Logger logger = lc.getLogger(LOGGER_NAME); final LoggingEvent event = simpleLoggingEvent(logger, null); final String logMsg = encodeToStr(event); final ObjectMapper om = new ObjectMapper(); final JsonNode jsonNode = om.readTree(logMsg); coreValidation(jsonNode); assertNotNull(jsonNode.get("_Thread").textValue()); assertEquals(LOGGER_NAME, jsonNode.get("_logger_name").textValue()); assertNull(jsonNode.get("_exception")); }
Example #10
Source File: LoggingConfiguration.java From tutorials with MIT License | 6 votes |
private void setMetricsMarkerLogbackFilter(LoggerContext context) { log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME); OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator(); onMarkerMetricsEvaluator.setContext(context); onMarkerMetricsEvaluator.addMarker("metrics"); onMarkerMetricsEvaluator.start(); EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>(); metricsFilter.setContext(context); metricsFilter.setEvaluator(onMarkerMetricsEvaluator); metricsFilter.setOnMatch(FilterReply.DENY); metricsFilter.start(); for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) { for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) { Appender<ILoggingEvent> appender = it.next(); if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) { log.debug("Filter metrics logs from the {} appender", appender.getName()); appender.setContext(context); appender.addFilter(metricsFilter); appender.start(); } } } }
Example #11
Source File: LogUtils.java From litchi with Apache License 2.0 | 6 votes |
public static void loadFileConfig(String configFilePath) throws IOException, JoranException { LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); File externalConfigFile = new File(configFilePath); if (!externalConfigFile.isFile()) { throw new IOException("logback config file not exists. configFilePath = " + configFilePath); } if (!externalConfigFile.canRead()) { throw new IOException("logback config file cannot be read. configFilePath = " + configFilePath); } JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(lc); lc.reset(); configurator.doConfigure(configFilePath); StatusPrinter.printInCaseOfErrorsOrWarnings(lc); }
Example #12
Source File: SingularityAbort.java From Singularity with Apache License 2.0 | 6 votes |
private void flushLogs() { final long millisToWait = 100; LOG.info( "Attempting to flush logs and wait {} ...", JavaUtils.durationFromMillis(millisToWait) ); ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory(); if (loggerFactory instanceof LoggerContext) { LoggerContext context = (LoggerContext) loggerFactory; context.stop(); } try { Thread.sleep(millisToWait); } catch (Exception e) { LOG.info("While sleeping for log flush", e); } }
Example #13
Source File: LogbackLoggingConfigurer.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private void doFailSafeConfiguration() { // Not really fail-safe, just less likely to fail final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); context.reset(); Logger rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME); rootLogger.setLevel(Level.INFO); ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>(); rootLogger.addAppender(appender); appender.setContext(context); appender.setTarget("System.err"); PatternLayout layout = new PatternLayout(); appender.setLayout(layout); layout.setPattern("%msg%n%ex"); layout.setContext(context); layout.start(); appender.start(); }
Example #14
Source File: LoggingConfiguration.java From tutorials with MIT License | 6 votes |
private void setMetricsMarkerLogbackFilter(LoggerContext context) { log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME); OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator(); onMarkerMetricsEvaluator.setContext(context); onMarkerMetricsEvaluator.addMarker("metrics"); onMarkerMetricsEvaluator.start(); EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>(); metricsFilter.setContext(context); metricsFilter.setEvaluator(onMarkerMetricsEvaluator); metricsFilter.setOnMatch(FilterReply.DENY); metricsFilter.start(); for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) { for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) { Appender<ILoggingEvent> appender = it.next(); if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) { log.debug("Filter metrics logs from the {} appender", appender.getName()); appender.setContext(context); appender.addFilter(metricsFilter); appender.start(); } } } }
Example #15
Source File: LoggingConfiguration.java From alchemy with Apache License 2.0 | 6 votes |
private void setMetricsMarkerLogbackFilter(LoggerContext context) { log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME); OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator(); onMarkerMetricsEvaluator.setContext(context); onMarkerMetricsEvaluator.addMarker("metrics"); onMarkerMetricsEvaluator.start(); EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>(); metricsFilter.setContext(context); metricsFilter.setEvaluator(onMarkerMetricsEvaluator); metricsFilter.setOnMatch(FilterReply.DENY); metricsFilter.start(); context.getLoggerList().forEach((logger) -> { for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) { Appender<ILoggingEvent> appender = it.next(); if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME) && !(appender.getName().equals(CONSOLE_APPENDER_NAME) && this.jHipsterProperties.getLogging().isUseJsonFormat())) { log.debug("Filter metrics logs from the {} appender", appender.getName()); appender.setContext(context); appender.addFilter(metricsFilter); appender.start(); } } }); }
Example #16
Source File: TwillContainerService.java From twill with Apache License 2.0 | 6 votes |
/** * Set the log level for the requested logger name. * * @param loggerName name of the logger * @param logLevel the log level to set to. * @return the current log level of the given logger. If there is no log level configured for the given logger or * if the logging implementation is not logback, {@code null} will be returned */ @Nullable private String setLogLevel(String loggerName, @Nullable String logLevel) { ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory(); if (!(loggerFactory instanceof LoggerContext)) { LOG.error("LoggerFactory is not a logback LoggerContext, cannot make the log level change"); return null; } LoggerContext loggerContext = (LoggerContext) loggerFactory; ch.qos.logback.classic.Logger logger = loggerContext.getLogger(loggerName); LogEntry.Level oldLogLevel = logger.getLevel() == null ? null : LogEntry.Level.valueOf(logger.getLevel().toString()); LOG.debug("Log level of {} changed from {} to {}", loggerName, oldLogLevel, logLevel); logger.setLevel(logLevel == null ? null : Level.toLevel(logLevel, Level.ERROR)); return oldLogLevel == null ? null : oldLogLevel.name(); }
Example #17
Source File: LogbackLoggingSystem.java From super-cloudops with Apache License 2.0 | 6 votes |
@Override protected void loadConfiguration(LoggingInitializationContext initializationContext, String location, LogFile logFile) { super.loadConfiguration(initializationContext, location, logFile); LoggerContext loggerContext = getLoggerContext(); stopAndReset(loggerContext); try { configureByResourceUrl(initializationContext, loggerContext, ResourceUtils.getURL(location)); } catch (Exception ex) { throw new IllegalStateException("Could not initialize Logback logging from " + location, ex); } List<Status> statuses = loggerContext.getStatusManager().getCopyOfStatusList(); StringBuilder errors = new StringBuilder(); for (Status status : statuses) { if (status.getLevel() == Status.ERROR) { errors.append(errors.length() > 0 ? String.format("%n") : ""); errors.append(status.toString()); } } if (errors.length() > 0) { throw new IllegalStateException(String.format("Logback configuration error detected: %n%s", errors)); } }
Example #18
Source File: LogbackUtilTest.java From otroslogviewer with Apache License 2.0 | 6 votes |
@Test public void testTranslate() throws Exception { //Given LoggerContext context = new LoggerContext(); Logger logger = context.getLogger("SomeLogger"); LoggingEvent le = new LoggingEvent("a.b.C",logger, ch.qos.logback.classic.Level.INFO,"message",null,null); final Map<String, String> split = Splitter.on(",").withKeyValueSeparator("=").split("a=b,b=as"); le.setMDCPropertyMap(split); le.setCallerData(new StackTraceElement[]{new StackTraceElement("a.b.C","someMethod","C.java",120)}); //when final LogData logData = LogbackUtil.translate(le).build(); //then assertEquals(logData.getMessage(),"message"); assertEquals(logData.getLevel(),Level.INFO); assertEquals(logData.getLoggerName(),"SomeLogger"); assertEquals(logData.getClazz(),"a.b.C"); assertEquals(logData.getMethod(),"someMethod"); assertEquals(logData.getLine(),"120"); assertEquals(logData.getProperties(),split); }
Example #19
Source File: LoggingConfiguration.java From e-commerce-microservice with Apache License 2.0 | 5 votes |
private void addLogstashAppender(LoggerContext context) { log.info("Initializing Logstash logging"); LogstashTcpSocketAppender logstashAppender = new LogstashTcpSocketAppender(); logstashAppender.setName(LOGSTASH_APPENDER_NAME); logstashAppender.setContext(context); String optionalFields = ""; String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"," + optionalFields + "\"version\":\"" + version + "\"}"; // More documentation is available at: https://github.com/logstash/logstash-logback-encoder LogstashEncoder logstashEncoder = new LogstashEncoder(); // Set the Logstash appender config from JHipster properties logstashEncoder.setCustomFields(customFields); // Set the Logstash appender config from JHipster properties logstashAppender.addDestinations(new InetSocketAddress(jHipsterProperties.getLogging().getLogstash().getHost(), jHipsterProperties.getLogging().getLogstash().getPort())); ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter(); throwableConverter.setRootCauseFirst(true); logstashEncoder.setThrowableConverter(throwableConverter); logstashEncoder.setCustomFields(customFields); logstashAppender.setEncoder(logstashEncoder); logstashAppender.start(); // Wrap the appender in an Async appender for performance AsyncAppender asyncLogstashAppender = new AsyncAppender(); asyncLogstashAppender.setContext(context); asyncLogstashAppender.setName(ASYNC_LOGSTASH_APPENDER_NAME); asyncLogstashAppender.setQueueSize(jHipsterProperties.getLogging().getLogstash().getQueueSize()); asyncLogstashAppender.addAppender(logstashAppender); asyncLogstashAppender.start(); context.getLogger("ROOT").addAppender(asyncLogstashAppender); }
Example #20
Source File: LogbackContainer.java From dubbox with Apache License 2.0 | 5 votes |
/** * Initializer logback * * @param file * @param level * @param maxHistory */ private void doInitializer(String file, String level, int maxHistory) { LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); rootLogger.detachAndStopAllAppenders(); // appender RollingFileAppender<ILoggingEvent> fileAppender = new RollingFileAppender<ILoggingEvent>(); fileAppender.setContext(loggerContext); fileAppender.setName("application"); fileAppender.setFile(file); fileAppender.setAppend(true); // policy TimeBasedRollingPolicy<ILoggingEvent> policy = new TimeBasedRollingPolicy<ILoggingEvent>(); policy.setContext(loggerContext); policy.setMaxHistory(maxHistory); policy.setFileNamePattern(file + ".%d{yyyy-MM-dd}"); policy.setParent(fileAppender); policy.start(); fileAppender.setRollingPolicy(policy); // encoder PatternLayoutEncoder encoder = new PatternLayoutEncoder(); encoder.setContext(loggerContext); encoder.setPattern("%date [%thread] %-5level %logger (%file:%line\\) - %msg%n"); encoder.start(); fileAppender.setEncoder(encoder); fileAppender.start(); rootLogger.addAppender(fileAppender); rootLogger.setLevel(Level.toLevel(level)); rootLogger.setAdditive(false); }
Example #21
Source File: ApplicationInfoEnricherTest.java From justtestlah with Apache License 2.0 | 5 votes |
@Test public void testStart() { target.setContext(new LoggerContext()); when(applicationInfoService.getAppInfo("/road/to/nowhere/android.apk")) .thenReturn(new ApplicationInfo("dummy", "test", "foo")); target.setApplicationInfoService(applicationInfoService); target.start(); assertThat(target.getContext().getProperty("appInfo")).isEqualTo("ANDROID dummy test_foo"); }
Example #22
Source File: LogsResource.java From angularjs-springboot-bookstore with MIT License | 5 votes |
@RequestMapping(value = "/logs", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.NO_CONTENT) @Timed public void changeLevel(@RequestBody LoggerDTO jsonLogger) { LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); context.getLogger(jsonLogger.getName()).setLevel(Level.valueOf(jsonLogger.getLevel())); }
Example #23
Source File: LogsResource.java From cubeai with Apache License 2.0 | 5 votes |
@GetMapping("/logs") @Timed public List<LoggerVM> getList() { LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); return context.getLoggerList() .stream() .map(LoggerVM::new) .collect(Collectors.toList()); }
Example #24
Source File: XodusEnvironmentImplLogLevelModificatorTest.java From hivemq-community-edition with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME); level = rootLogger.getLevel(); rootLogger.setLevel(Level.TRACE); context.addTurboFilter(new XodusEnvironmentImplLogLevelModificator()); context.getLogger("jetbrains.exodus").setLevel(Level.TRACE); }
Example #25
Source File: DefaultLogbackConfigurator.java From lambda-monitoring with Apache License 2.0 | 5 votes |
@Override public void configure(LoggerContext loggerContext) { addInfo("Setting up default configuration."); DefaultConsoleAppender consoleAppender = new DefaultConsoleAppender(); consoleAppender.setContext(loggerContext); consoleAppender.setName("CONSOLE"); consoleAppender.start(); Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); rootLogger.setLevel(Level.INFO); rootLogger.addAppender(consoleAppender); }
Example #26
Source File: LogsResource.java From expper with GNU General Public License v3.0 | 5 votes |
@RequestMapping(value = "/logs", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public List<LoggerDTO> getList() { LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); return context.getLoggerList() .stream() .map(LoggerDTO::new) .collect(Collectors.toList()); }
Example #27
Source File: LogsResource.java From gpmr with Apache License 2.0 | 5 votes |
@RequestMapping(value = "/logs", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public List<LoggerDTO> getList() { LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); return context.getLoggerList() .stream() .map(LoggerDTO::new) .collect(Collectors.toList()); }
Example #28
Source File: MessagesTest.java From cuba with Apache License 2.0 | 5 votes |
public MessagesTest() { appender = new TestAppender(); appender.start(); LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); Logger logger = context.getLogger("com.haulmont.cuba.core.sys.AbstractMessages"); logger.addAppender(appender); logger.setLevel(Level.TRACE); }
Example #29
Source File: XodusFileDataWriterLogLevelModificatorSingularityTest.java From hivemq-community-edition with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { context = (LoggerContext) LoggerFactory.getILoggerFactory(); rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME); level = rootLogger.getLevel(); rootLogger.setLevel(Level.DEBUG); context.addTurboFilter(new XodusFileDataWriterLogLevelModificator()); context.getLogger("jetbrains.exodus").setLevel(Level.DEBUG); }
Example #30
Source File: LogsResource.java From tutorials with MIT License | 5 votes |
@PutMapping("/logs") @ResponseStatus(HttpStatus.NO_CONTENT) @Timed public void changeLevel(@RequestBody LoggerVM jsonLogger) { LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); context.getLogger(jsonLogger.getName()).setLevel(Level.valueOf(jsonLogger.getLevel())); }