Git Product home page Git Product logo

slf4j-jboss-logging's Introduction

JBoss Logging

JBoss Logging is a logging facade which can bind to different log managers allowing your applications to be log manager agnostic.

Usage

JBoss Logging is similar to other logging facades in the way you get a logger and log messages. One thing to note is the format style log methods will only format the message if the log level is enabled. This helps with performance of objects which may have complex toString() methods.

private static final Logger LOGGER = Logger.getLogger(Customer.class);

public Customer getCustomer(final int id) {
    LOGGER.debugf("Looking up customer %d", id);
    try {
        final Customer customer = findCustomer(id);
        LOGGER.tracef("Found customer: %s", customer);
        return customer;
    } catch (Exception e) {
        LOGGER.errorf(e, "Error looking up customer %d", id);
    }
    return null;
}

Supported Log Managers

The following are the supported log managers and listed in the order the attempt to discover the provider is done.

  1. JBoss Log Manager

  2. Log4j 2

  3. SLF4J and Logback

  4. log4j (note this log manager is EOL’d)

  5. Java Util Logging

You can define the specific log manager you want to use by specifying the org.jboss.logging.provider system property. The following is the mapping of the property value to the log manager.

Property Value Log Manager

jboss

JBoss Log Manager

jdk

Java Util Logging

log4j2

Log4j 2

log4j

log4j

slf4j

SLF4J and Logback

Custom Provider

You can also implement your own org.jboss.logging.LoggerProvider which would be loaded from a ServiceLoader. Simply implement the API and add a META-INF/services/org.jboss.logging.LoggerProvider file with the fully qualified class name of your implementation to your library. If the system property is not defined, your implementation should be discovered.

Maven Dependency

<dependency>
    <groupId>org.jboss.logging</groupId>
    <artifactId>jboss-logging</artifactId>
    <version>${version.org.jboss.logging}</version>
</dependency>

Contributing

slf4j-jboss-logging's People

Contributors

dependabot[bot] avatar dmlloyd avatar garyttierney avatar jamezp avatar jhult avatar slyngdk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

slf4j-jboss-logging's Issues

Multiple SLF4J Binding warning

Is it possible to mix this with logback or not?

SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/C:/Java/vfabric-tc-server-developer-2.8.2.RELEASE/base-instance/wtpwebapps/settleinv/WEB-INF/lib/logback-classic-1.0.11.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/C:/Java/vfabric-tc-server-developer-2.8.2.RELEASE/base-instance/wtpwebapps/settleinv/WEB-INF/lib/slf4j-jboss-logging-1.0.4.GA.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder] Apr 26, 2013 12:14:18 PM org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring root WebApplicationContext

Upgrade slf4j 2.0.6

Upgrade from 1.7.21 to [2.0.5|https://mvnrepository.com/artifact/org.slf4j/slf4j-api/2.0.6]

  • [FAQ 2.0|https://www.slf4j.org/faq.html#changesInVersion200]
  • [Git-Tag|https://github.com/qos-ch/slf4j/releases/tag/v_2.0.6]
  • [Git-Diff|https://github.com/qos-ch/slf4j/compare/v_1.7.21...v_2.0.6]

Replaces https://issues.redhat.com/browse/JBLOGGING-165

Add a README to give more information about the project

A README should be added which informs users and contributors about the project. For contributors there should be a link to some kind of contributors guide. For users it would be nice to have say the Maven GAV and describe what the project actually does.

Add a codeowners file

This allows contributors to know who the code owners are as well as ping the code owner when there is a new PR.

MDC.getCopyOfMDC() returns original reference when using SLF4J

JBossMDCAdapter.java line 59 return the original map, rather than a copy of the map, as the method name would suggest.

This can result in unanticipated behavior.

To re-create the issue:

// put value
MDC.put("foo", "bar");

// get copy of MDC
Map copy = MDC.getCopyOfContextMap();

// clear MDC
MDC.clear();

// reset to the original copy
MDC.setContextMap(copy);

System.out.println("MDC.get(\"foo\"): " + MDC.get("foo"));

Do not use the 2.0.x version for the 1.7.x static binding

SLF4J 1.x uses static binding to determine the implementation. This includes a field:

public static String REQUESTED_API_VERSION = "2.0.6";

This version should be moved back to a 1.7.x version even though we compile against 2.0.6 currently. We do test against 1.7 and we should just use that version. Without this change when using 1.7.x the following warning is logged:

SLF4J: The requested version 2.0.6 by your slf4j binding is not compatible with [1.6, 1.7]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.