Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问一下能否修改日志格式 #183

Open
EricDeng1001 opened this issue Jul 28, 2023 · 2 comments
Open

请问一下能否修改日志格式 #183

EricDeng1001 opened this issue Jul 28, 2023 · 2 comments

Comments

@EricDeng1001
Copy link

我希望可以看到线程号以便于不同类之间的日志做匹配,谢谢!

@SpCoGov
Copy link

SpCoGov commented Jan 17, 2024

解决了吗

@SpCoGov
Copy link

SpCoGov commented Jan 17, 2024

我发现在插件里重写 MiraiLogger.Factory没用所以我修改了mcl的源代码:package org.itxtech.mcl

import net.mamoe.mirai.utils.MiraiInternalApi
import net.mamoe.mirai.utils.MiraiLogger
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.MarkerManager

/**

  • @author SpCo
  • @Version 2.0.0
  • @SInCE 2.0.0
    /
    @MiraiInternalApi
    public class MiraiLog4JFactory : MiraiLogger.Factory {
    override fun create(requester: Class<
    >, identity: String?): MiraiLogger {
    val logger = LogManager.getLogger(requester)
    @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
    return net.mamoe.mirai.internal.utils.Log4jLoggerAdapter(
    logger,
    MarkerManager.getMarker(identity ?: logger.name).addParents(net.mamoe.mirai.internal.utils.MARKER_MIRAI)
    )
    }
    } 不知道有没有更简单的方法

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants