Giter VIP home page Giter VIP logo

mirai-slf4j-bridge's People

Contributors

cssxsh avatar karlatemp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

cssxsh cauchydoom

mirai-slf4j-bridge's Issues

插件模式 在 mirai 2.12.0 下失效

原因可能是类隔离机制导致 对 LoggerFactory 的修改失效

kotlin.runCatching {
Class.forName("android.view.View")
// Unsafe 100% 无法在 Android 平台工作
logger.error("Mirai Logger Binding Slf4j with Console Plugin mode NOT SUPPORTED on Android")
}.onFailure {
// 如果不使用 Unsafe, 将无法修改 static final 字段
val unsafe = Unsafe.getUnsafe()
val LF = LoggerFactory::class.java
unsafe.ensureClassInitialized(LF)
val field = LF.getDeclaredField("NOP_FALLBACK_FACTORY")
val LFBase = unsafe.staticFieldBase(field)
val LFOffset = unsafe.staticFieldOffset(field)
unsafe.putReference(LFBase, LFOffset, MiraiLoggerSlf4jFactoryNOP)
val INITIALIZATION_STATE = LF.getDeclaredField("INITIALIZATION_STATE")
val NOP_FALLBACK_INITIALIZATION = LF.getDeclaredField("NOP_FALLBACK_INITIALIZATION")
Root.openAccess(INITIALIZATION_STATE)
Root.openAccess(NOP_FALLBACK_INITIALIZATION)
INITIALIZATION_STATE.setInt(null, NOP_FALLBACK_INITIALIZATION.getInt(null))
logger.debug("SLF4J LOGGER FACTORY = " + LoggerFactory.getILoggerFactory())
}
}

org.slf4j.MDC 初始化失败

SLF4J: Failed to load class "org.slf4j.impl.StaticMDCBinder".
SLF4J: Defaulting to no-operation MDCAdapter implementation.
SLF4J: See http://www.slf4j.org/codes.html#no_static_mdc_binder for further details.

补充信息,这里调用slf4j 是 org.jboss.logging 的 桥接

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.