Java Code Examples for ch.qos.logback.classic.Logger#setLevel()
The following examples show how to use
ch.qos.logback.classic.Logger#setLevel() .
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: LogbackLoggingConfigurer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private void doConfigure(LogLevel logLevel) { LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); Logger rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME); if (currentLevel == null) { context.reset(); context.addTurboFilter(new GradleFilter()); context.getLogger("org.apache.http.wire").setLevel(Level.OFF); context.getLogger("org.codehaus.groovy.runtime.m12n.MetaInfExtensionModule").setLevel(Level.ERROR); GradleAppender appender = new GradleAppender(); appender.setContext(context); appender.start(); rootLogger.addAppender(appender); } currentLevel = logLevel; rootLogger.setLevel(LogLevelConverter.toLogbackLevel(logLevel)); }
Example 2
Source File: LogbackController.java From GreenSummer with GNU Lesser General Public License v2.1 | 6 votes |
/** * Frees the given logger from the appender used to be displayed directly by * this controller. * * @param name The name of the logger we want to free from being captured * @return The list of log levels configured and their settings */ @RequestMapping(value = "free/{name}/", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET, headers = "Accept=application/json") @ResponseBody public ResponseEntity<LogResponse> free(@PathVariable("name") final String name) { final LoggerContext ctx = (LoggerContext) LoggerFactory.getILoggerFactory(); synchronized (ctx) { Logger logger = ctx.getLogger(name); if (logger != null) { logger.setLevel(null); logger.detachAppender(logbackMemoryAppenderImpl.getName()); } } return new ResponseEntity<>(listLoggers(ctx), HttpStatus.OK); }
Example 3
Source File: DatatypeBenchmarkLinear.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Setup(Level.Iteration) public void setUp() { Logger root = (Logger) LoggerFactory.getLogger(ShaclSailConnection.class.getName()); root.setLevel(ch.qos.logback.classic.Level.INFO); allStatements = new ArrayList<>(NUMBER_OF_TRANSACTIONS); SimpleValueFactory vf = SimpleValueFactory.getInstance(); for (int j = 0; j < NUMBER_OF_TRANSACTIONS; j++) { List<Statement> statements = new ArrayList<>(BenchmarkConfigs.STATEMENTS_PER_TRANSACTION); allStatements.add(statements); for (int i = 0; i < BenchmarkConfigs.STATEMENTS_PER_TRANSACTION; i++) { IRI iri = vf.createIRI("http://example.com/" + i + "_" + j); statements.add(vf.createStatement(iri, RDF.TYPE, RDFS.RESOURCE)); statements.add(vf.createStatement(iri, FOAF.AGE, vf.createLiteral(i))); } } System.gc(); }
Example 4
Source File: VerboseHandler.java From swagger-brake with Apache License 2.0 | 6 votes |
@Override public void handle(String optionValue, Options options) { if (optionValue == null) { return; } if (optionValue.isEmpty()) { org.slf4j.Logger slf4jLogger = LoggerFactory.getLogger("io.redskap.swagger.brake"); if (slf4jLogger instanceof Logger) { Logger logger = (Logger) slf4jLogger; logger.setLevel(Level.DEBUG); Appender<ILoggingEvent> verboseAppender = getVerboseAppender(); if (verboseAppender != null) { logger.detachAppender("INFO_STDOUT"); logger.addAppender(verboseAppender); } } } }
Example 5
Source File: MaxCountBenchmarkEmpty.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Setup(Level.Invocation) public void setUp() { Logger root = (Logger) LoggerFactory.getLogger(ShaclSailConnection.class.getName()); root.setLevel(ch.qos.logback.classic.Level.INFO); SimpleValueFactory vf = SimpleValueFactory.getInstance(); allStatements = BenchmarkConfigs.generateStatements(((statements, i, j) -> { IRI iri = vf.createIRI("http://example.com/" + i + "_" + j); statements.add(vf.createStatement(iri, RDF.TYPE, RDFS.RESOURCE)); statements.add(vf.createStatement(iri, RDFS.LABEL, vf.createLiteral("label" + i))); })); System.gc(); }
Example 6
Source File: LogUtil.java From nuls-v2 with MIT License | 6 votes |
public static void configDefaultLog(String fileName, String packageLogPackages, String packageLogLevels) { Log.DEFAULT_BASIC_LOGGER = LoggerBuilder.getLogger(fileName); Log.DEFAULT_BASIC_LOGGER.addBasicPath(Log.class.getName()); if (StringUtils.isNotBlank(packageLogPackages) && StringUtils.isNotBlank(packageLogLevels)) { LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); String[] packages = packageLogPackages.split(","); String[] levels = packageLogLevels.split(","); int levelsLength = levels.length; String packagePath; String logLevel; Logger packageLogger; for (int i = 0, length = packages.length; i < length; i++) { packagePath = packages[i]; if(i >= levelsLength) { logLevel = "INFO"; } else { logLevel = levels[i]; } packageLogger = context.getLogger(packagePath); packageLogger.setLevel(Level.toLevel(logLevel)); } } }
Example 7
Source File: LoggerService.java From che with Eclipse Public License 2.0 | 5 votes |
@POST @Path("/{name}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Create a new logger level") @ApiResponses({ @ApiResponse(code = 200, message = "The logger successfully created"), }) public LoggerDto createLogger( @ApiParam(value = "logger name") @PathParam("name") String name, LoggerDto createdLogger) throws NotFoundException { Logger logger = getLogger(name, false); logger.setLevel(Level.toLevel(createdLogger.getLevel())); return asDto(logger); }
Example 8
Source File: RequestContextExportingAppenderTest.java From armeria with Apache License 2.0 | 5 votes |
@BeforeEach void setUp(TestInfo testInfo) { rootLogger.getLoggerContext().getStatusManager().clear(); MDC.clear(); testLogger = (Logger) LoggerFactory.getLogger("loggerTest." + testInfo.getDisplayName()); testLogger.setLevel(Level.ALL); }
Example 9
Source File: SaeControllerTest.java From SmartApplianceEnabler with GNU General Public License v2.0 | 5 votes |
@BeforeEach public void setup() throws Exception { System.setProperty(FileHandler.SAE_HOME, System.getProperty("java.io.tmpdir")); this.mockMvc = webAppContextSetup(webApplicationContext).build(); this.now = LocalDateTime.now(); Logger root = (Logger) LoggerFactory.getLogger("de.avanux"); root.setLevel(Level.DEBUG); }
Example 10
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 11
Source File: TestLogAppender.java From karate with MIT License | 5 votes |
public TestLogAppender() { sb = new StringBuilder(); logger = (Logger) LoggerFactory.getLogger("com.intuit.karate"); setName("karate-test"); LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); setContext(lc); encoder = new PatternLayoutEncoder(); encoder.setPattern("%msg"); encoder.setContext(context); encoder.start(); start(); logger.addAppender(this); logger.setLevel(Level.DEBUG); }
Example 12
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 13
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 14
Source File: LogLevelTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testLevelsThatDoNotMatchSlf4jAreMapped() { Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); logger.setLevel(Level.WARN); setParameters.execute("set", "log"); verify(mockConsoleIO).writeln("log: warning"); verifyNoMoreInteractions(mockConsoleIO); }
Example 15
Source File: AbstractWorkflowIT.java From telekom-workflow-engine with MIT License | 4 votes |
@BeforeClass public static void beforeClass(){ Logger log = (Logger)LoggerFactory.getLogger( WorkflowExecutorImpl.class ); executorLogLevel = log.getLevel(); log.setLevel( Level.ERROR ); }
Example 16
Source File: ConfigTest.java From sshd-shell-spring-boot with Apache License 2.0 | 4 votes |
public ConfigTest() { LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); rootLogger.setLevel(Level.INFO); }
Example 17
Source File: Framework.java From Heracles with GNU General Public License v3.0 | 4 votes |
public static void suppressJenaMessages() { Logger root = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); root.setLevel(Level.INFO); }
Example 18
Source File: LocalRateLimiterTest.java From pay-publicapi with MIT License | 4 votes |
@Before public void setup() { Logger root = (Logger) LoggerFactory.getLogger(LocalRateLimiter.class); root.setLevel(Level.INFO); root.addAppender(mockAppender); }
Example 19
Source File: CompilerDependencyResolutionTests.java From spring-cloud-function with Apache License 2.0 | 4 votes |
/** * Doesn't actually verify the caching helps but can be useful to run to see current * numbers. */ @Test public void speedtest() { LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); Logger rootLogger = loggerContext .getLogger("org.springframework.cloud.function.compiler"); rootLogger.setLevel(Level.ERROR); // 10 uses of a single function compiler: long stime = System.currentTimeMillis(); FunctionCompiler<String, String> fc = new FunctionCompiler<String, String>( String.class.getName()); for (int i = 0; i < 5; i++) { stime = System.currentTimeMillis(); CompiledFunctionFactory<Function<String, String>> result = fc.compile("foos", "flux -> flux.map(v -> v.toUpperCase())", "Flux<String>", "Flux<String>"); assertThat(FunctionFactoryUtils.isFluxFunction(result.getFactoryMethod())) .isTrue(); System.out.println("Reusing FunctionCompiler: #" + (i + 1) + " = " + (System.currentTimeMillis() - stime) + "ms"); } // 3 separate FunctionCompilers: stime = System.currentTimeMillis(); CompiledFunctionFactory<Function<String, String>> compiled = new FunctionCompiler<String, String>( String.class.getName()).compile("foos", "flux -> flux.map(v -> v.toUpperCase())", "Flux<String>", "Flux<String>"); assertThat(FunctionFactoryUtils.isFluxFunction(compiled.getFactoryMethod())) .isTrue(); long etime = System.currentTimeMillis(); long time1 = (etime - stime); System.out.println("New FunctionCompiler: " + time1 + "ms"); stime = System.currentTimeMillis(); compiled = new FunctionCompiler<String, String>(String.class.getName()).compile( "foos", "flux -> flux.map(v -> v.toUpperCase())", "Flux<String>", "Flux<String>"); assertThat(FunctionFactoryUtils.isFluxFunction(compiled.getFactoryMethod())) .isTrue(); etime = System.currentTimeMillis(); long time2 = (etime - stime); System.out.println("New FunctionCompiler: " + time2 + "ms"); stime = System.currentTimeMillis(); compiled = new FunctionCompiler<String, String>(String.class.getName()).compile( "foos", "flux -> flux.map(v -> v.toUpperCase())", "Flux<String>", "Flux<String>"); assertThat(FunctionFactoryUtils.isFluxFunction(compiled.getFactoryMethod())) .isTrue(); etime = System.currentTimeMillis(); long time3 = (etime - stime); System.out.println("New FunctionCompiler: " + time3 + "ms"); }
Example 20
Source File: YOLO2_TF_Client.java From SKIL_Examples with Apache License 2.0 | 3 votes |
public void run() throws Exception, IOException { Logger root = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); root.setLevel(Level.INFO); globalStartTime = System.nanoTime(); // kick off the javaFX rendering code --> .start( Stage ) below, blocked on the skil model server round trips for { auth, inference } launch(); }