Java Code Examples for org.jboss.logging.Logger#getLogger()

The following examples show how to use org.jboss.logging.Logger#getLogger() . 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: Timing.java    From quarkus with Apache License 2.0 6 votes vote down vote up
public static void printStartupTime(String name, String version, String quarkusVersion, String features, String profile,
        boolean liveCoding) {
    final long bootTimeNanoSeconds = System.nanoTime() - bootStartTime;
    final Logger logger = Logger.getLogger("io.quarkus");
    //Use a BigDecimal so we can render in seconds with 3 digits precision, as requested:
    final BigDecimal secondsRepresentation = convertToBigDecimalSeconds(bootTimeNanoSeconds);
    String safeAppName = (name == null || name.trim().isEmpty()) ? UNSET_VALUE : name;
    String safeAppVersion = (version == null || version.trim().isEmpty()) ? UNSET_VALUE : version;
    final String nativeOrJvm = ImageInfo.inImageRuntimeCode() ? "native" : "on JVM";
    if (UNSET_VALUE.equals(safeAppName) || UNSET_VALUE.equals(safeAppVersion)) {
        logger.infof("Quarkus %s %s started in %ss. %s", quarkusVersion, nativeOrJvm, secondsRepresentation,
                httpServerInfo);
    } else {
        logger.infof("%s %s %s (powered by Quarkus %s) started in %ss. %s", name, version, nativeOrJvm, quarkusVersion,
                secondsRepresentation, httpServerInfo);
    }
    logger.infof("Profile %s activated. %s", profile, liveCoding ? "Live Coding activated." : "");
    logger.infof("Installed features: [%s]", features);
    bootStartTime = -1;
}
 
Example 2
Source File: LoggingExceptionHandler.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private void handleCustomLog(HttpServerExchange exchange, Throwable t, Logger.Level level, Logger.Level stackTraceLevel, String category) {
    BasicLogger logger = UndertowLogger.REQUEST_LOGGER;
    if (!category.isEmpty()) {
        logger = Logger.getLogger(category);
    }
    boolean stackTrace = true;
    if (stackTraceLevel.ordinal() > level.ordinal()) {
        if (!logger.isEnabled(stackTraceLevel)) {
            stackTrace = false;
        }
    }
    if (stackTrace) {
        logger.logf(level, t, "Exception handling request to %s", exchange.getRequestURI());
    } else {
        logger.logf(level, "Exception handling request to %s: %s", exchange.getRequestURI(), t.getMessage());
    }
}
 
Example 3
Source File: SWARM553Test.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Test
public void doLogging() throws FileNotFoundException {
    String message = "testing: " + UUID.randomUUID().toString();
    Logger logger = Logger.getLogger("br.org.sistemafieg.cliente");
    logger.info(message);
    assertTrue("File not found: " + logFile, new File(logFile).exists());

    BufferedReader reader = new BufferedReader(new FileReader(logFile));
    List<String> lines = reader.lines().collect(Collectors.toList());

    boolean found = false;

    for (String line : lines) {
        if (line.contains(message)) {
            found = true;
            break;
        }
    }

    assertTrue("Expected message " + message, found);


}
 
Example 4
Source File: QuarkusExceptionHandler.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private void handleCustomLog(HttpServerExchange exchange, Throwable t, Logger.Level level, Logger.Level stackTraceLevel,
        String category, String uid) {
    BasicLogger logger = UndertowLogger.REQUEST_LOGGER;
    if (!category.isEmpty()) {
        logger = Logger.getLogger(category);
    }
    boolean stackTrace = true;
    if (stackTraceLevel.ordinal() > level.ordinal()) {
        if (!logger.isEnabled(stackTraceLevel)) {
            stackTrace = false;
        }
    }
    if (stackTrace) {
        logger.logf(level, t, "Exception handling request %s to %s", uid, exchange.getRequestURI());
    } else {
        logger.logf(level, "Exception handling request %s to %s: %s", uid, exchange.getRequestURI(), t.getMessage());
    }
}
 
Example 5
Source File: ArqLoggingLevelsTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Test
public void testRoot() {
    Logger logger = Logger.getLogger("");

    logger.info("gouda info");
    logger.debug("gouda debug");
    logger.trace("gouda trace");

    assertTrue(logger.isTraceEnabled());
    assertTrue(logger.isDebugEnabled());
    assertTrue(logger.isInfoEnabled());
}
 
Example 6
Source File: ArqLoggingLevelsTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Test
public void testCustomCategoryChildren() {
    Logger logger = Logger.getLogger("custom.category.children.Something");

    logger.info("gouda info");
    logger.debug("gouda debug");
    logger.trace("gouda trace");

    assertFalse(logger.isTraceEnabled());
    assertTrue(logger.isDebugEnabled());
    assertTrue(logger.isInfoEnabled());
}
 
Example 7
Source File: CamelBootstrapRecorder.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
public void start(RuntimeValue<CamelRuntime> runtime, Supplier<String[]> arguments) {
    try {
        Logger logger = Logger.getLogger(CamelBootstrapRecorder.class);
        logger.infof("bootstrap runtime: %s", runtime.getValue().getClass().getName());
        runtime.getValue().start(arguments.get());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 8
Source File: JBossLoggingAccessLogReceiver.java    From quarkus with Apache License 2.0 4 votes vote down vote up
public JBossLoggingAccessLogReceiver(final String category) {
    this.logger = Logger.getLogger(category);
}
 
Example 9
Source File: LoggerProducer.java    From packt-java-ee-7-code-samples with GNU General Public License v2.0 4 votes vote down vote up
@Produces
public Logger produceLoger(InjectionPoint injectionPoint) {
    return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
}
 
Example 10
Source File: HEMLogging.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public static Logger logger(Class classNeedingLogging) {
	return Logger.getLogger( classNeedingLogging );
}
 
Example 11
Source File: LoggingInterceptor.java    From packt-java-ee-7-code-samples with GNU General Public License v2.0 4 votes vote down vote up
@AroundInvoke
public Object log(InvocationContext context) throws Exception {
    final Logger logger = Logger.getLogger(context.getTarget().getClass());
    logger.infov("Executing method {0}", context.getMethod().toString());
    return context.proceed();
}
 
Example 12
Source File: Loggable.java    From keycloak with Apache License 2.0 4 votes vote down vote up
default public Logger logger() {
    return Logger.getLogger(this.getClass());
}
 
Example 13
Source File: LoggerProducer.java    From java-ml-projects with Apache License 2.0 4 votes vote down vote up
@Produces
public Logger produceLogger(InjectionPoint injectionPoint) {
	return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
}
 
Example 14
Source File: JBossLoggingAccessLogReceiver.java    From quarkus with Apache License 2.0 4 votes vote down vote up
public JBossLoggingAccessLogReceiver() {
    this.logger = Logger.getLogger(DEFAULT_CATEGORY);
}
 
Example 15
Source File: JBossLoggingManager.java    From thorntail with Apache License 2.0 4 votes vote down vote up
@Override
public BackingLogger getBackingLogger(String name) {
    return new JBossLoggingLogger(Logger.getLogger(name));
}
 
Example 16
Source File: DatawaveUsersRolesLoginModule.java    From datawave with Apache License 2.0 4 votes vote down vote up
public DatawaveUsersRolesLoginModule() {
    log = Logger.getLogger(getClass());
}
 
Example 17
Source File: LoggerContext.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private JBossLoggingModuleLogger() {
    logger = Logger.getLogger("org.jboss.modules");
    defineLogger = Logger.getLogger("org.jboss.modules.define");
}
 
Example 18
Source File: TestEventsLogger.java    From keycloak with Apache License 2.0 4 votes vote down vote up
private Logger log(Description d) {
    return Logger.getLogger(d.getClassName());
}
 
Example 19
Source File: JBossLoggingAccessLogReceiver.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
public JBossLoggingAccessLogReceiver() {
    this.logger = Logger.getLogger(DEFAULT_CATEGORY);
}
 
Example 20
Source File: JBossLoggingApacheLoggerBridge.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
public JBossLoggingApacheLoggerBridge(String name) {
   bridgeLog = Logger.getLogger(name);
}