org.slf4j.LoggerFactory Java Examples
The following examples show how to use
org.slf4j.LoggerFactory.
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: MetricsConfiguration.java From cubeai with Apache License 2.0 | 7 votes |
@PostConstruct public void init() { log.debug("Registering JVM gauges"); metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet()); metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge()); metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); metricRegistry.register(PROP_METRIC_REG_JVM_ATTRIBUTE_SET, new JvmAttributeGaugeSet()); if (jHipsterProperties.getMetrics().getJmx().isEnabled()) { log.debug("Initializing Metrics JMX reporting"); JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build(); jmxReporter.start(); } if (jHipsterProperties.getMetrics().getLogs().isEnabled()) { log.info("Initializing Metrics Log reporting"); Marker metricsMarker = MarkerFactory.getMarker("metrics"); final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry) .outputTo(LoggerFactory.getLogger("metrics")) .markWith(metricsMarker) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS); } }
Example #2
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 #3
Source File: ConsumerActions.java From apicurio-registry with Apache License 2.0 | 6 votes |
/** * Dynamically remove given topic partition from the set of assigned topic partitions. * * @param tp topic partition to remove */ default CompletableFuture<Void> removeTopicParition(TopicPartition tp) { Objects.requireNonNull(tp); Logger log = LoggerFactory.getLogger(DynamicAssignment.class); log.info("Removing topic-partition: {}", tp); return submit(consumer -> { Set<TopicPartition> oldTps = consumer.assignment(); Set<TopicPartition> newTps = new HashSet<>(oldTps); newTps.remove(tp); if (!oldTps.equals(newTps)) { log.info("Reassigning topic-partition(s): {} -> {}", oldTps, newTps); consumer.assign(newTps); } return null; }); }
Example #4
Source File: LogBackConfiguration.java From summerframework with Apache License 2.0 | 6 votes |
@Override public void init() { LoggerContext loggerContext = (LoggerContext)LoggerFactory.getILoggerFactory(); if (loggerContext == null) return; List<Logger> loggerList = loggerContext.getLoggerList(); ch.qos.logback.classic.Logger loggerKafka = loggerContext.getLogger("org.apache.kafka.clients.producer.ProducerConfig"); if (loggerKafka != null) { loggerKafka.setLevel(ch.qos.logback.classic.Level.ERROR); } createBizLogger(); for (Logger logger : loggerList) { AppenderAttachable appenderAttachable = logger; setLayout(loggerContext,appenderAttachable.iteratorForAppenders()); } }
Example #5
Source File: HtmlMakerFactory.java From bitchat with Apache License 2.0 | 6 votes |
public static void main(String[] args) { int loopTimes = 200; class Runner implements Runnable { private Logger logger = LoggerFactory.getLogger(Runner.class); @Override public void run() { HtmlMakerFactory factory = HtmlMakerFactory.instance(); logger.info("factory={},currentThread={}", (factory != null ? factory.getClass().getName() : "null"), Thread.currentThread().getName()); } } for (int i = 0; i < loopTimes; i++) { new Thread(new Runner()).start(); } }
Example #6
Source File: TestOzoneManagerRatisServer.java From hadoop-ozone with Apache License 2.0 | 6 votes |
/** * Test that all of {@link OzoneManagerProtocolProtos.Type} enum values are * categorized in {@link OmUtils#isReadOnly(OMRequest)}. */ @Test public void testIsReadOnlyCapturesAllCmdTypeEnums() throws Exception { GenericTestUtils.LogCapturer logCapturer = GenericTestUtils.LogCapturer .captureLogs(LoggerFactory.getLogger(OmUtils.class)); OzoneManagerProtocolProtos.Type[] cmdTypes = OzoneManagerProtocolProtos.Type.values(); for (OzoneManagerProtocolProtos.Type cmdtype : cmdTypes) { OMRequest request = OMRequest.newBuilder() .setCmdType(cmdtype) .setClientId(clientId) .build(); OmUtils.isReadOnly(request); assertFalse(cmdtype + " is not categorized in " + "OmUtils#isReadyOnly", logCapturer.getOutput().contains("CmdType " + cmdtype +" is not " + "categorized as readOnly or not.")); logCapturer.clearOutput(); } }
Example #7
Source File: AnalyzerFactoryTestCase.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("unused") private List<String> toQueryTermString(String field, String str) { List<String> result = new ArrayList<>(); try { TokenStream stream = analyzerFactory.getQueryAnalyzer().tokenStream(field, new StringReader(str)); stream.reset(); while (stream.incrementToken()) { result.add(stream.getAttribute(CharTermAttribute.class).toString() .replaceAll("^term\\=", "")); } stream.close(); } catch (IOException e) { LoggerFactory.getLogger(AnalyzerFactoryTestCase.class) .error("Error during Token processing.", e); } return result; }
Example #8
Source File: MetricsConfiguration.java From cubeai with Apache License 2.0 | 6 votes |
@PostConstruct public void init() { log.debug("Registering JVM gauges"); metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet()); metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge()); metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); metricRegistry.register(PROP_METRIC_REG_JVM_ATTRIBUTE_SET, new JvmAttributeGaugeSet()); if (jHipsterProperties.getMetrics().getJmx().isEnabled()) { log.debug("Initializing Metrics JMX reporting"); JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build(); jmxReporter.start(); } if (jHipsterProperties.getMetrics().getLogs().isEnabled()) { log.info("Initializing Metrics Log reporting"); Marker metricsMarker = MarkerFactory.getMarker("metrics"); final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry) .outputTo(LoggerFactory.getLogger("metrics")) .markWith(metricsMarker) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS); } }
Example #9
Source File: WebContainerAccessLogAutoConfiguration.java From spring-cloud-formula with Apache License 2.0 | 6 votes |
private AccessLogHandler createAccessLogHandler(HttpHandler handler) { Logger logger = LoggerFactory.getLogger("accesslog"); try { /* ref nginx log format: '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; */ AccessLogReceiver accessLogReceiver = logger::info; String formatString = "%h %l %u [%t] \"%r\" %s %b \"%{i,Referer}\"" + " \"%{i,User-Agent}\" \"%{i,X-Forwarded-For}\" %D"; return new AccessLogHandler(handler, accessLogReceiver, formatString, Undertow.class.getClassLoader()); } catch (Exception ex) { throw new IllegalStateException("Failed to create AccessLogHandler", ex); } }
Example #10
Source File: JsonHandlerExceptionResolver.java From sca-best-practice with Apache License 2.0 | 6 votes |
private ExceptionMetadata logException(Object handler, HttpServletRequest request, Exception exception) { ExceptionMetadata exceptionMetadata = new ExceptionMetadata(); try { buildExceptionMetadata(exceptionMetadata, handler, request); if (exceptionMetadata.isHandlerMethod()) { Logger logger = LoggerFactory.getLogger(exceptionMetadata.getBeanType()); logger.error("Error id is :" + exceptionMetadata.getErrorId()); logger.error("RequestMapping is:"); logger.error(exceptionMetadata.getRequestMapping()); logger.error("HandlerMethod is:"); logger.error(exceptionMetadata.getMethodName()); logger.error("ParameterMap is:"); logger.error(exceptionMetadata.getParameterMap(), exception); } else { log.error(handler + " execute failed, error id is:" + exceptionMetadata.getErrorId(), exception); } } catch (Exception e) { log.error(handler + " execute failed.", exception); } return exceptionMetadata; }
Example #11
Source File: AnnotationUtils.java From beihu-boot with Apache License 2.0 | 6 votes |
/** * Handle the supplied annotation introspection exception. * it will simply be thrown, allowing it to propagate to the caller, and * nothing will be logged. * <p>Otherwise, this method logs an introspection failure (in particular * {@code TypeNotPresentExceptions}) before moving on, assuming nested * Class values were not resolvable within annotation attributes and * thereby effectively pretending there were no annotations on the specified * element. * * @param element the element that we tried to introspect annotations on * @param ex the exception that we encountered * @see #rethrowAnnotationConfigurationException */ static void handleIntrospectionFailure(AnnotatedElement element, Throwable ex) { rethrowAnnotationConfigurationException(ex); Logger loggerToUse = logger; if (loggerToUse == null) { loggerToUse = LoggerFactory.getLogger(AnnotationUtils.class); logger = loggerToUse; } if (element instanceof Class && Annotation.class.isAssignableFrom((Class<?>) element)) { // Meta-annotation lookup on an annotation type if (loggerToUse.isDebugEnabled()) { loggerToUse.debug("Failed to introspect meta-annotations on [" + element + "]: " + ex); } } else { // Direct annotation lookup on regular Class, Method, Field if (loggerToUse.isInfoEnabled()) { loggerToUse.info("Failed to introspect annotations on [" + element + "]: " + ex); } } }
Example #12
Source File: MetricsConfiguration.java From cubeai with Apache License 2.0 | 6 votes |
@PostConstruct public void init() { log.debug("Registering JVM gauges"); metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet()); metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge()); metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); metricRegistry.register(PROP_METRIC_REG_JVM_ATTRIBUTE_SET, new JvmAttributeGaugeSet()); if (jHipsterProperties.getMetrics().getJmx().isEnabled()) { log.debug("Initializing Metrics JMX reporting"); JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build(); jmxReporter.start(); } if (jHipsterProperties.getMetrics().getLogs().isEnabled()) { log.info("Initializing Metrics Log reporting"); Marker metricsMarker = MarkerFactory.getMarker("metrics"); final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry) .outputTo(LoggerFactory.getLogger("metrics")) .markWith(metricsMarker) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS); } }
Example #13
Source File: TestForEachActionTemplate.java From arcusplatform with Apache License 2.0 | 6 votes |
@Before public void init(){ this.context = new SimpleContext(UUID.randomUUID(), this.source, LoggerFactory.getLogger(TestForEachActionTemplate.class)); SimpleModel model = new SimpleModel(); model.setAttribute(Capability.ATTR_ID, modelAddress.toString()); model.setAttribute(Capability.ATTR_TYPE, DeviceCapability.NAMESPACE); model.setAttribute(Capability.ATTR_ADDRESS, modelAddress.getRepresentation()); context.putModel(model); logTemplate = new LogTemplate(); logTemplate.setMessage(TemplatedValue.text("hello ${value}")); template = new ForEachModelTemplate(ImmutableSet.<String>of("address")); template.setActions(ImmutableList.of(logTemplate,logTemplate)); template.setQuery(new TemplatedExpression(modelQuery)); template.setVar("address"); }
Example #14
Source File: BaseRawKVStore.java From sofa-jraft with Apache License 2.0 | 6 votes |
@Override public void execute(final NodeExecutor nodeExecutor, final boolean isLeader, final KVStoreClosure closure) { final Timer.Context timeCtx = getTimeContext("EXECUTE"); try { if (nodeExecutor != null) { nodeExecutor.execute(Status.OK(), isLeader); } setSuccess(closure, Boolean.TRUE); } catch (final Exception e) { final Logger LOG = LoggerFactory.getLogger(getClass()); LOG.error("Fail to [EXECUTE], {}.", StackTraceUtil.stackTrace(e)); if (nodeExecutor != null) { nodeExecutor.execute(new Status(RaftError.EIO, "Fail to [EXECUTE]"), isLeader); } setCriticalError(closure, "Fail to [EXECUTE]", e); } finally { timeCtx.stop(); } }
Example #15
Source File: TestPlatformRuleContext.java From arcusplatform with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { super.setUp(); placeId = UUID.randomUUID(); address = Address.platformService(UUID.randomUUID(), RuleCapability.NAMESPACE, 1); context = PlatformRuleContext .builder() .withLogger(LoggerFactory.getLogger(TestPlatformRuleContext.class)) .withModels(new RuleModelStore()) .withPlatformBus(platformBus) .withEventLoop(eventLoop) .withPlaceId(placeId) .withSource(address) .withTimeZone(TimeZone.getDefault()) .build(); }
Example #16
Source File: MetricsConfiguration.java From flair-registry with Apache License 2.0 | 6 votes |
@PostConstruct public void init() { log.debug("Registering JVM gauges"); metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet()); metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge()); metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); if (jHipsterProperties.getMetrics().getJmx().isEnabled()) { log.debug("Initializing Metrics JMX reporting"); JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build(); jmxReporter.start(); } if (jHipsterProperties.getMetrics().getLogs().isEnabled()) { log.info("Initializing Metrics Log reporting"); Marker metricsMarker = MarkerFactory.getMarker("metrics"); final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry) .outputTo(LoggerFactory.getLogger("metrics")) .markWith(metricsMarker) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS); } }
Example #17
Source File: ScheduleTemplateImpl.java From reliable with Apache License 2.0 | 5 votes |
public boolean schedule(Class scheduleClazz, Callable<Boolean> callable) { Logger logger = LoggerFactory.getLogger(scheduleClazz); String loggingName = scheduleClazz.getSimpleName(); boolean flag = false; long startTime = System.currentTimeMillis(); String taskId = loggingName + "_" + startTime; logger.info("Executing {}, At: {}, id: {}", loggingName, new Date(), taskId); try { flag = callable.call(); }catch (Exception e) { logger.info("Exception Occured: {}" ,ExceptionUtil.getMessage(e)); } long endTime = System.currentTimeMillis(); String result = flag == true?"OK," : "FAILED,"; logger.info("Executing {}, {}, Cost: {}ms id: {}", loggingName, result, (endTime - startTime), taskId); return flag; }
Example #18
Source File: ContainerUtils.java From hadoop-ozone with Apache License 2.0 | 5 votes |
/** * Verifies that this is indeed a new container. * * @param containerFile - Container File to verify * @throws FileAlreadyExistsException */ public static void verifyIsNewContainer(File containerFile) throws FileAlreadyExistsException { Logger log = LoggerFactory.getLogger(ContainerSet.class); Preconditions.checkNotNull(containerFile, "containerFile Should not be " + "null"); if (containerFile.getParentFile().exists()) { log.error("Container already exists on disk. File: {}", containerFile .toPath()); throw new FileAlreadyExistsException("container already exists on " + "disk."); } }
Example #19
Source File: LoggingBootstrapTest.java From hivemq-community-edition with Apache License 2.0 | 5 votes |
public void resetLogToOriginal() throws Exception { final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); context.reset(); final JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(context); configurator.doConfigure(this.getClass().getClassLoader().getResource("logback-test.xml")); }
Example #20
Source File: HupuHotProcessor.java From hot-crawler with MIT License | 5 votes |
@Override @PostConstruct protected void initialize(){ RequestMethod requestMethod = RequestMethod.GET; setFieldsByProperties(siteProperties, requestMethod, generateHeader(),generateRequestBody()); injectBeansByContext(context); setLog(LoggerFactory.getLogger(getClass())); }
Example #21
Source File: DefaultPlaceExecutorFactory.java From arcusplatform with Apache License 2.0 | 5 votes |
private void initialize(RuleEnvironment environment, DefaultPlaceExecutor executor) { TimeZone tz = getTimeZone(environment.getPlaceId(), executor.getModelStore()); // TODO make this pluggable List<PlaceEventHandler> handlers = new ArrayList<>(); { RuleCatalog catalog = ruleCatalogLoader.getCatalogForPlace(environment.getPlaceId()); PlatformRuleContext.Builder builder = PlatformRuleContext .builder() .withEventLoop(eventLoop) .withPlatformBus(platformBus) .withPlaceId(environment.getPlaceId()) .withModels(executor.getModelStore()) .withTimeZone(tz) ; for(RuleDefinition definition: environment.getRules()) { Address address = Address.platformService(definition.getId().getRepresentation(), RuleCapability.NAMESPACE); builder.withSource(address); builder.withVariables(definition.getVariables()); builder.withLogger(LoggerFactory.getLogger("rules." + definition.getRuleTemplate())); Rule rule = instantiate(catalog, definition, builder.build(), environment, address); if(rule == null) { definition.setDisabled(true); } else { RuleTemplate template = catalog.getById(definition.getRuleTemplate()); boolean premium = template != null && template.isPremium(); handlers.add(new RuleHandler(rule, definition, ruleDefDao, premium)); } } } List<SceneHandler> sceneHandlers = sceneHandlerFactory.create(environment, executor.getModelStore()); handlers.addAll(sceneHandlers); executor.setHandlers(handlers); }
Example #22
Source File: LogbackLevelSetter.java From summerframework with Apache License 2.0 | 5 votes |
@Override public void setLoggerLevel(String name, String level) { LoggerContext loggerContext = (LoggerContext)LoggerFactory.getILoggerFactory(); List<Logger> loggerList = loggerContext.getLoggerList(); for (ch.qos.logback.classic.Logger logger : loggerList) { if (name.equals(logger.getName())) { logger.setLevel(Level.valueOf(level)); } } }
Example #23
Source File: TestConfig.java From iot-mqtt with Apache License 2.0 | 5 votes |
public TestConfig(String configPath) { super(configPath); LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(lc); lc.reset(); try { configurator.doConfigure(getLogBackXmlPath()); } catch (JoranException e) { e.printStackTrace(); } }
Example #24
Source File: RuleService.java From arcusplatform with Apache License 2.0 | 5 votes |
private RuleContext createSimpleRuleContext(UUID placeId) { PlaceEnvironmentExecutor executor = registry.getExecutor(placeId).orNull(); Collection<Model> models = executor != null ? executor.getModelStore().getModels() : modelDao.loadModelsByPlace(placeId, RuleModelStore.TRACKED_TYPES); // use a simple context just for resolving SimpleContext context = new SimpleContext(placeId, Address.platformService("rule"), LoggerFactory.getLogger("rules." + placeId)); models.stream().filter((m) -> m != null).forEach((m) -> context.putModel(m)); return context; }
Example #25
Source File: JiandanHotProcessor.java From hot-crawler with MIT License | 5 votes |
@Override @PostConstruct protected void initialize(){ RequestMethod requestMethod = RequestMethod.GET; setFieldsByProperties(siteProperties, requestMethod, generateHeader(),generateRequestBody()); injectBeansByContext(context); setLog(LoggerFactory.getLogger(getClass())); this.elementClass = ITEM_KEY; }
Example #26
Source File: LogsResource.java From cubeai with Apache License 2.0 | 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())); }
Example #27
Source File: TestOverrideNamespaceContext.java From arcusplatform with Apache License 2.0 | 5 votes |
@Before public void setUp() { delegate = new SimpleContext(UUID.randomUUID(), Address.platformService(UUID.randomUUID(), "rule"), LoggerFactory.getLogger(TestThresholdTrigger.class)); delegate.setVariable("_baseVar", "basevalue"); delegate.clearDirty(); context1 = new NamespaceContext("context1", delegate); context2 = new NamespaceContext("context2", delegate); }
Example #28
Source File: IrisStdioHijack.java From arcusplatform with Apache License 2.0 | 5 votes |
private void hijackStdio() { Logger stdoutLogger = LoggerFactory.getLogger("stdout"); Logger stderrLogger = LoggerFactory.getLogger("stderr"); PrintStream newOut = new PrintStream(new StdioOutputStream(stdoutLogger)); PrintStream newErr = new PrintStream(new StdioOutputStream(stderrLogger)); System.setOut(newOut); System.setErr(newErr); }
Example #29
Source File: ClosureShardingAlgorithm.java From sharding-jdbc-1.5.1 with Apache License 2.0 | 5 votes |
public ClosureShardingAlgorithm(final String expression, final String logRoot) { Preconditions.checkArgument(!Strings.isNullOrEmpty(expression)); Preconditions.checkArgument(!Strings.isNullOrEmpty(logRoot)); Binding binding = new Binding(); binding.setVariable("log", LoggerFactory.getLogger(Joiner.on(".").join("com.dangdang.ddframe.rdb.sharding.configFile", logRoot.trim()))); closureTemplate = (Closure) new GroovyShell(binding).evaluate(Joiner.on("").join("{it -> \"", expression.trim(), "\"}")); }
Example #30
Source File: LogbackUtil.java From summerframework with Apache License 2.0 | 5 votes |
private static Logger buildInfoByLevel(String name, Level logLevel, String fileName) { RollingFileAppender appender = new AppenderBuild().getAppender(name, logLevel, fileName); LoggerContext context = (LoggerContext)LoggerFactory.getILoggerFactory(); Logger logger = context.getLogger(name); logger.setAdditive(false); logger.addAppender(appender); return logger; }