org.slf4j.Logger Java Examples
The following examples show how to use
org.slf4j.Logger.
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: AvvisoPagamentoPdf.java From govpay with GNU General Public License v3.0 | 6 votes |
public JRDataSource creaXmlDataSource(Logger log,AvvisoPagamentoInput input) throws UtilsException, JRException, JAXBException { // WriteToSerializerType serType = WriteToSerializerType.XML_JAXB; Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); jaxbMarshaller.setProperty("com.sun.xml.bind.xmlDeclaration", Boolean.FALSE); ByteArrayOutputStream baos = new ByteArrayOutputStream(); JAXBElement<AvvisoPagamentoInput> jaxbElement = new JAXBElement<AvvisoPagamentoInput>(new QName("", "input"), AvvisoPagamentoInput.class, null, input); jaxbMarshaller.marshal(jaxbElement, baos); JRDataSource dataSource = new JRXmlDataSource(new ByteArrayInputStream(baos.toByteArray()),AvvisoPagamentoCostanti.AVVISO_PAGAMENTO_ROOT_ELEMENT_NAME); return dataSource; }
Example #2
Source File: LoggingConfiguration.java From java-microservices-examples with Apache License 2.0 | 6 votes |
private void addLogstashTcpSocketAppender(LoggerContext context) { log.info("Initializing Logstash logging"); // More documentation is available at: https://github.com/logstash/logstash-logback-encoder LogstashTcpSocketAppender logstashAppender = new LogstashTcpSocketAppender(); logstashAppender.addDestinations(new InetSocketAddress(this.jHipsterProperties.getLogging().getLogstash().getHost(), this.jHipsterProperties.getLogging().getLogstash().getPort())); logstashAppender.setContext(context); logstashAppender.setEncoder(logstashEncoder()); logstashAppender.setName(LOGSTASH_APPENDER_NAME); 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(this.jHipsterProperties.getLogging().getLogstash().getQueueSize()); asyncLogstashAppender.addAppender(logstashAppender); asyncLogstashAppender.start(); context.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME).addAppender(asyncLogstashAppender); }
Example #3
Source File: LoggingAspect.java From jhipster-registry with Apache License 2.0 | 6 votes |
/** * Advice that logs when a method is entered and exited. * * @param joinPoint join point for advice. * @return result. * @throws Throwable throws {@link IllegalArgumentException}. */ @Around("applicationPackagePointcut() && springBeanPointcut()") public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable { Logger log = logger(joinPoint); if (log.isDebugEnabled()) { log.debug("Enter: {}() with argument[s] = {}", joinPoint.getSignature().getName(), Arrays.toString(joinPoint.getArgs())); } try { Object result = joinPoint.proceed(); if (log.isDebugEnabled()) { log.debug("Exit: {}() with result = {}", joinPoint.getSignature().getName(), result); } return result; } catch (IllegalArgumentException e) { log.error("Illegal argument: {} in {}()", Arrays.toString(joinPoint.getArgs()), joinPoint.getSignature().getName()); throw e; } }
Example #4
Source File: PrettyPrinter.java From googleads-java-lib with Apache License 2.0 | 6 votes |
/** * Default constructor used by Guice. Takes {@link Supplier} instances for {@link XPath}, * {@link Transformer}, and {@link DocumentBuilder} because the corresponding factory objects are * <em>not</em> thread-safe. The Guice modules creating these suppliers should guarantee that the * {@link Supplier} <em>is</em> thread-safe, however. * * @param adsApiConfiguration the API configuration * @param libLogger the logger to use for errors * @param xpathSupplier a thread-safe supplier of {@link XPath} objects * @param transformerSupplier a thread-safe supplier of {@link Transformer} objects * @param documentBuilderSupplier a thread-safe supplier of {@link DocumentBuilder} objects */ @Inject public PrettyPrinter( AdsApiConfiguration adsApiConfiguration, @Named("libLogger") Logger libLogger, Supplier<XPath> xpathSupplier, Supplier<Transformer> transformerSupplier, Supplier<DocumentBuilder> documentBuilderSupplier) { String[] sensitiveXPathsArray = adsApiConfiguration.getSensitiveXPaths(); this.sensitiveXPathStrings = sensitiveXPathsArray == null ? ImmutableList.<String>of() : ImmutableList.<String>copyOf(sensitiveXPathsArray); this.libLogger = libLogger; this.xpathSupplier = xpathSupplier; this.transformerSupplier = transformerSupplier; this.documentBuilderSupplier = documentBuilderSupplier; }
Example #5
Source File: RocksDbTtlCompactFiltersManager.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private static org.rocksdb.Logger createRocksDbNativeLogger() { if (LOG.isDebugEnabled()) { // options are always needed for org.rocksdb.Logger construction (no other constructor) // the logger level gets configured from the options in native code try (DBOptions opts = new DBOptions().setInfoLogLevel(InfoLogLevel.DEBUG_LEVEL)) { return new org.rocksdb.Logger(opts) { @Override protected void log(InfoLogLevel infoLogLevel, String logMsg) { LOG.debug("RocksDB filter native code log: " + logMsg); } }; } } else { return null; } }
Example #6
Source File: GPUtils.java From GlobalPlatformPro with GNU Lesser General Public License v3.0 | 6 votes |
static void trace_tlv(byte[] data, Logger l) { BerTlvParser parser = new BerTlvParser(); BerTlvs tlvs = parser.parse(data); BerTlvLogger.log("", tlvs, new IBerTlvLogger() { @Override public boolean isDebugEnabled() { return true; } @Override public void debug(String s, Object... objects) { l.trace(s, objects); } } ); }
Example #7
Source File: BrokerLoggerTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Test public void testTurningLoggingOff() { Map<String, Object> fooRuleAttributes = createBrokerNameAndLevelLogInclusionRuleAttributes("fooRule", "org.apache.qpid.foo.*", LogLevel.INFO); Map<String, Object> barRuleAttributes = createBrokerNameAndLevelLogInclusionRuleAttributes("barRule", "org.apache.qpid.foo.bar", LogLevel.OFF); _brokerLogger.createChild(BrokerLogInclusionRule.class, fooRuleAttributes); _brokerLogger.createChild(BrokerLogInclusionRule.class, barRuleAttributes); Logger barLogger = LoggerFactory.getLogger("org.apache.qpid.foo.bar"); barLogger.warn("bar message"); Logger fooLogger = LoggerFactory.getLogger("org.apache.qpid.foo.foo"); fooLogger.warn("foo message"); assertLoggedEvent(_loggerAppender, false, "bar message", barLogger.getName(), Level.WARN); assertLoggedEvent(_loggerAppender, false, "bar message", fooLogger.getName(), Level.WARN); assertLoggedEvent(_loggerAppender, true, "foo message", fooLogger.getName(), Level.WARN); }
Example #8
Source File: Splash.java From Arraybot with Apache License 2.0 | 6 votes |
/** * Prints the splash. * @param logger The logger that should print. */ public void print(Logger logger, String version, String jdaVersion, String developers) { try { if(file.createNewFile()) { BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.write("SPLASH TEXT - CUSTOMISE IN " + file.getName() + "!"); writer.close(); } printBlank(logger); BufferedReader bufferedReader = new BufferedReader(new FileReader(file)); String line; while((line = bufferedReader.readLine()) != null) { logger.info(line, version, jdaVersion, developers); } bufferedReader.close(); printBlank(logger); } catch(IOException exception) { logger.error("An error occurred showing the splash.", exception); } }
Example #9
Source File: PropertyExecutor.java From velocity-engine with Apache License 2.0 | 6 votes |
/** * @param log * @param introspector * @param clazz * @param property * @param wrapArray * @since 1.5 */ public PropertyExecutor(final Logger log, final Introspector introspector, final Class clazz, final String property, final boolean wrapArray) { this.log = log; this.introspector = introspector; this.wrapArray = wrapArray; // Don't allow passing in the empty string or null because // it will either fail with a StringIndexOutOfBounds error // or the introspector will get confused. if (StringUtils.isNotEmpty(property)) { discover(clazz, property); } }
Example #10
Source File: WebServer.java From Web-API with MIT License | 6 votes |
WebServer(Logger logger, MainConfig config) { this.logger = logger; this.config = config; // Process the config.js file to include data from the Web-API config files try { MainConfig.APConfig cfg = config.adminPanelConfig; if (cfg != null) { ObjectMapper om = new ObjectMapper(); String configStr = "window.config = " + om.writeValueAsString(cfg); apConfig = configStr.getBytes(Charset.forName("utf-8")); } } catch (JsonProcessingException e) { e.printStackTrace(); } }
Example #11
Source File: JDBCDominioServiceSearchImpl.java From govpay with GNU General Public License v3.0 | 5 votes |
@Override public List<List<Object>> nativeQuery(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, String sql,List<Class<?>> returnClassTypes,Object ... param) throws ServiceException,NotFoundException,NotImplementedException,Exception{ return org.openspcoop2.generic_project.dao.jdbc.utils.JDBCUtilities.nativeQuery(jdbcProperties, log, connection, sqlQueryObject, sql,returnClassTypes,param); }
Example #12
Source File: BootstrapTools.java From flink with Apache License 2.0 | 5 votes |
/** * Starts an Actor System at a specific port. * * @param configuration The Flink configuration. * @param listeningAddress The address to listen at. * @param listeningPort The port to listen at. * @param logger the logger to output log information. * @return The ActorSystem which has been started. * @throws Exception */ public static ActorSystem startActorSystem( Configuration configuration, String listeningAddress, int listeningPort, Logger logger) throws Exception { return startActorSystem( configuration, listeningAddress, listeningPort, logger, ForkJoinExecutorConfiguration.fromConfiguration(configuration)); }
Example #13
Source File: JDBCDominioServiceSearchImpl.java From govpay with GNU General Public License v3.0 | 5 votes |
@Override public Map<String,Object> aggregate(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException,Exception { org.openspcoop2.generic_project.dao.jdbc.utils.JDBCUtilities.setFields(sqlQueryObject,expression,functionField); try{ List<Map<String,Object>> list = this._select(jdbcProperties, log, connection, sqlQueryObject, expression); return list.get(0); }finally{ org.openspcoop2.generic_project.dao.jdbc.utils.JDBCUtilities.removeFields(sqlQueryObject,expression,functionField); } }
Example #14
Source File: StatusConfigReporter.java From nifi-minifi with Apache License 2.0 | 5 votes |
private static void handleControllerServices(RequestItem requestItem, FlowController flowController, List<ControllerServiceStatus> controllerServiceStatusList, Logger logger) { Collection<ControllerServiceNode> controllerServiceNodeSet = flowController.getAllControllerServices(); if (!controllerServiceNodeSet.isEmpty()) { for (ControllerServiceNode controllerServiceNode : controllerServiceNodeSet) { controllerServiceStatusList.add(parseControllerServiceStatusRequest(controllerServiceNode, requestItem.options, flowController, logger)); } } }
Example #15
Source File: JDBCPagamentoPortaleServiceImpl.java From govpay with GNU General Public License v3.0 | 5 votes |
@Override public void updateOrCreate(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdPagamentoPortale oldId, PagamentoPortale pagamentoPortale, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotImplementedException,ServiceException,Exception { // default behaviour (id-mapping) if(idMappingResolutionBehaviour==null){ idMappingResolutionBehaviour = org.openspcoop2.generic_project.beans.IDMappingBehaviour.valueOf("USE_TABLE_ID"); } if(this.exists(jdbcProperties, log, connection, sqlQueryObject, oldId)) { this.update(jdbcProperties, log, connection, sqlQueryObject, oldId, pagamentoPortale,idMappingResolutionBehaviour); } else { this.create(jdbcProperties, log, connection, sqlQueryObject, pagamentoPortale,idMappingResolutionBehaviour); } }
Example #16
Source File: HugeSecurityManager.java From hugegraph with Apache License 2.0 | 5 votes |
private static SecurityException newSecurityException(String message, Object... args) { if (args.length > 0) { message = String.format(message, args); } /* * use dynamic logger here because "static final logger" can't be * initialized: the logger is not initialized when HugeSecurityManager * class is loaded */ Logger log = Log.logger(HugeSecurityManager.class); log.warn("SecurityException: {}", message); return new SecurityException(message); }
Example #17
Source File: AtlasEntityStoreV1BulkImportPercentTest.java From incubator-atlas with Apache License 2.0 | 5 votes |
@BeforeClass void mockLog() { log = mock(Logger.class); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); Integer d = (Integer) args[1]; percentHolder.add(d.intValue()); return null; } }).when(log).info(anyString(), anyFloat(), anyInt(), anyString()); }
Example #18
Source File: JDBCDominioServiceSearchImpl.java From govpay with GNU General Public License v3.0 | 5 votes |
@Override public List<Object> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCPaginatedExpression paginatedExpression, boolean distinct, IField field) throws ServiceException,NotFoundException,NotImplementedException,Exception { List<Map<String,Object>> map = this.select(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression, distinct, new IField[]{field}); return org.openspcoop2.generic_project.dao.jdbc.utils.JDBCUtilities.selectSingleObject(map); }
Example #19
Source File: DistributedSystemIdConfiguration.java From spring-boot-data-geode with Apache License 2.0 | 5 votes |
@Bean ClientCacheConfigurer clientCacheDistributedSystemIdConfigurer() { return (beanName, clientCacheFactoryBean) -> getDistributedSystemId().ifPresent(distributedSystemId -> { Logger logger = getLogger(); if (logger.isWarnEnabled()) { logger.warn("Distributed System Id [{}] was set on the ClientCache instance, which will not have any effect", distributedSystemId); } }); }
Example #20
Source File: MesosCallbackHandler.java From attic-aurora with Apache License 2.0 | 5 votes |
private static void logStatusUpdate(Logger logger, TaskStatus status) { // Periodic task reconciliation runs generate a large amount of no-op messages. // Suppress logging for reconciliation status updates by default. boolean debugLevel = status.hasReason() && status.getReason() == REASON_RECONCILIATION; StringBuilder message = new StringBuilder("Received status update for task ") .append(status.getTaskId().getValue()) .append(" in state ") .append(status.getState()); if (status.hasSource()) { message.append(" from ").append(status.getSource()); } if (status.hasReason()) { message.append(" with ").append(status.getReason()); } if (status.hasMessage()) { String[] lines = status.getMessage().split("\n"); message.append(": ").append(lines[0]); if (lines.length > 1) { message.append(" (truncated)"); } } if (debugLevel) { logger.debug(message.toString()); } else { logger.info(message.toString()); } }
Example #21
Source File: EventReschedulerTest.java From android-sdk with Apache License 2.0 | 5 votes |
@Before public void setupEventRescheduler() { context = mock(Context.class); intent = mock(Intent.class); logger = mock(Logger.class); rescheduler = mock(EventRescheduler.class); rescheduler = new EventRescheduler(); rescheduler.logger = logger; }
Example #22
Source File: DataflowWorkerHarnessHelper.java From beam with Apache License 2.0 | 5 votes |
public static void initializeLogging(Class<?> workerHarnessClass) { /* Set up exception handling tied to the workerHarnessClass. */ Thread.setDefaultUncaughtExceptionHandler( new WorkerUncaughtExceptionHandler(LoggerFactory.getLogger(workerHarnessClass))); // Reset the global log manager, get the root logger and remove the default log handlers. LogManager logManager = LogManager.getLogManager(); logManager.reset(); java.util.logging.Logger rootLogger = logManager.getLogger(ROOT_LOGGER_NAME); for (Handler handler : rootLogger.getHandlers()) { rootLogger.removeHandler(handler); } DataflowWorkerLoggingInitializer.initialize(); }
Example #23
Source File: DefaultJobLeaderService.java From flink with Apache License 2.0 | 5 votes |
JobManagerRegisteredRpcConnection( Logger log, String targetAddress, JobMasterId jobMasterId, Executor executor) { super(log, targetAddress, jobMasterId, executor); }
Example #24
Source File: SystemController.java From kylin with Apache License 2.0 | 5 votes |
@RequestMapping(value = "/logLevel/{loggerName}", method = RequestMethod.GET, produces = { "application/json" }) @ResponseBody public String getLogLevel(@PathVariable(value = "loggerName") String loggerName) { org.apache.log4j.Logger logger = org.apache.log4j.LogManager.getLogger(loggerName); org.apache.log4j.Level level = logger.getEffectiveLevel(); if (level != null) { return level.toString(); } return null; }
Example #25
Source File: JDBCStampaServiceSearchImpl.java From govpay with GNU General Public License v3.0 | 5 votes |
@Override public JDBCPaginatedExpression newPaginatedExpression(Logger log) throws NotImplementedException, ServiceException { try{ return new JDBCPaginatedExpression(this.getStampaFieldConverter()); }catch(Exception e){ throw new ServiceException(e); } }
Example #26
Source File: JDBCOperatoreServiceImpl.java From govpay with GNU General Public License v3.0 | 5 votes |
@Override public void updateFields(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, UpdateModel ... updateModels) throws NotFoundException, NotImplementedException, ServiceException, Exception { java.util.List<Object> ids = new java.util.ArrayList<>(); ids.add(tableId); JDBCUtilities.updateFields(jdbcProperties, log, connection, sqlQueryObject, this.getOperatoreFieldConverter().toTable(Operatore.model()), this._getMapTableToPKColumn(), ids, this.getOperatoreFieldConverter(), this, updateModels); }
Example #27
Source File: RequestBlocksHandlerTest.java From aion with MIT License | 5 votes |
@Test public void testReceive_correctMessage_nullValue_withHash() { Block first = consecutiveBlocks.get(0); byte[] hash = first.getHash(); Block last = consecutiveBlocks.get(3); Logger log = mock(Logger.class); when(log.isDebugEnabled()).thenReturn(true); IAionBlockchain chain = mock(AionBlockchainImpl.class); when(chain.getBlockByHash(hash)).thenReturn(first); when(chain.getBlocksByRange(first.getNumber(), last.getNumber())).thenReturn(null); IP2pMgr p2p = mock(P2pMgr.class); RequestBlocksHandler handler = new RequestBlocksHandler(log, chain, p2p); // receive correct message byte[] encoding = RLP.encodeList( RLP.encodeByte(isFalse), RLP.encode(hash), RLP.encodeInt(4), RLP.encodeByte(isFalse)); handler.receive(peerId, displayId, encoding); verify(log, times(1)) .debug( "<request-blocks from-block={} count={} order={}>", Hex.toHexString(hash), 4, "ASC"); verify(chain, times(1)).getBlockByHash(hash); verify(chain, times(1)).getBlocksByRange(first.getNumber(), last.getNumber()); ResponseBlocks expectedResponse = new ResponseBlocks(List.of(first)); verify(p2p, times(1)).send(peerId, displayId, expectedResponse); }
Example #28
Source File: Slf4jSessionLogger.java From gazpachoquest with GNU General Public License v3.0 | 5 votes |
@Override public void log(final SessionLogEntry entry) { if (!shouldLog(entry.getLevel(), entry.getNameSpace())) { return; } Logger logger = getLogger(entry.getNameSpace()); LogLevel logLevel = getLogLevel(entry.getLevel()); StringBuilder message = new StringBuilder(); message.append(getSupplementDetailString(entry)); message.append(formatMessage(entry)); switch (logLevel) { case TRACE: logger.trace(message.toString()); break; case DEBUG: logger.debug(message.toString()); break; case INFO: logger.info(message.toString()); break; case WARN: logger.warn(message.toString()); break; case ERROR: logger.error(message.toString()); break; default: throw new IllegalStateException("Not supported" + logLevel); } }
Example #29
Source File: ReloadLogHelper.java From dble with GNU General Public License v2.0 | 5 votes |
public static void info(String message, Logger logger) { if (ReloadManager.getReloadInstance().getStatus() != null) { logger.info(ReloadManager.getReloadInstance().getStatus().getLogStage() + message); } else { logger.info(message); } }
Example #30
Source File: WebappUberspector.java From velocity-tools with Apache License 2.0 | 5 votes |
/** * @param log logger * @param introspector introspector instance * @param clazz target class * @param arg value to set * @param property property name */ public SetAttributeExecutor(final Logger log, final Introspector introspector, final Class clazz, final Object arg, final String property) { this.log = log; this.introspector = introspector; this.property = property; discover(clazz, arg); }