SLF4J

Java简单日志门面。(Simple Logging Facade for Java.)

  • Owner: qos-ch/slf4j
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

Java 简单日志门面(SLF4J)作为简单的外观或抽象,可用于各种日志记录框架(例如java.util.logging,logback,log4j),允许最终用户在部署时插入所需的日志记录框架。

什么时候应该使用SLF4J?(原文:https://www.slf4j.org/faq.html#when

简而言之,库和其他嵌入式组件应考虑SLF4J的日志记录需求,因为库无法在最终用户上强加他们对日志记录框架的选择。另一方面,独立应用程序使用SLF4J并不一定有意义。独立应用程序可以直接调用他们选择的日志记录框架。在logback的情况下,这个问题是没有实际意义的,因为logback通过SLF4J公开其logger API。
SLF4J只是一个门面,这意味着它不提供完整的记录解决方案。 SLF4J无法执行诸如配置追加者或设置日志级别等操作。因此,在某个时间点,任何重要的应用程序都需要直接调用底层日志记录系统。换句话说,独立应用程序不可能完全独立于API底层日志记录系统。然而,SLF4J将这种依赖性的影响降低到接近无痛水平。
假设您的CRM应用程序使用log4j进行日志记录。但是,您的一个重要客户端请求通过JDK 1.4日志记录来执行日志记录。如果您的应用程序充满了数千个直接的log4j调用,则迁移到JDK 1.4将是一个相对冗长且容易出错的过程。更糟糕的是,您可能需要维护两个版本的CRM软件。如果您一直在调用SLF4J API而不是log4j,则可以在几分钟内完成迁移,将另一个jar文件替换为另一个。

SLF4J允许组件开发人员将登录系统的选择推迟到最终用户,但最终需要进行选择。

Overview

Name With Ownerqos-ch/slf4j
Primary LanguageJava
Program languageJava (Language Count: 3)
Platform
License:MIT License
Release Count98
Last Release Namev_2.0.13 (Posted on 2024-04-12 18:04:18)
First Release NameSLF4J_1.0RC4 (Posted on 2009-08-20 18:03:36)
Created At2009-08-20 16:25:49
Pushed At2024-04-12 16:05:32
Last Commit At2024-04-12 18:05:28
Stargazers Count2.3k
Watchers Count111
Fork Count1k
Commits Count2.1k
Has Issues Enabled
Issues Count34
Issue Open Count26
Pull Requests Count121
Pull Requests Open Count110
Pull Requests Close Count107
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

About SLF4J

The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks (e.g. java.util.logging, logback, log4j) allowing the end user to plug in the desired logging framework at deployment time.
More information can be found on the SLF4J website.

Build Status

Build Status

How to build SLF4J

SLF4J uses Maven as its build tool.

All versions upto and including 1.7.x require Java 5 or later to
build. SLF4J version 2.0.x requires Java 9 or later.

How to contribute pull requests

If you are interested in improving SLF4J, that is great! The SLF4J
community looks forward to your contribution. Please follow this
process:

  1. Start a discussion on the slf4j-dev mailing
    list
    about your proposed
    change. Alternately, file a bug
    report
    to initiatite the
    discussion. Note that we usually ask most pull requests to be linked
    to a Jira ticket.

  2. Fork qos-ch/slf4j. Ideally, create a new branch from your fork for
    your contribution to make it easier to merge your changes back.

  3. Make your changes on the branch you hopefuly created in Step 2. Be
    sure that your code passes existing unit tests. Please add unit tests
    for your work if appropriate. It usually is.

  4. Push your changes to your fork/branch in github. Don't push it to
    your master! If you do it will make it harder to submit new changes
    later.

  5. Submit a pull request to SLF4J from from your commit page on github.

  6. Did we mention that you will be asked to link your pull request
    with a Jira ticket?

To the top