0

我使用 jboss 日志记录。根据https://jboss-logging.github.io/jboss-logging-tools/#message-bundle-interfaces,有两种类型:

  • @MessageLogger 用于日志消息
  • @MessageBundle 用于异常和字符串消息

我不知道这是如何在内部处理的,但使用

@MessageLogger(projectCode = "TESTLOGGER", length = 3)
public interface TestLogger {

    // This is not a log message, but a string message
    @Message(id=1, value = "invalid {0}", format = Message.Format.MESSAGE_FORMAT)
    void test(String dateString);
    
    // this is a typical log message
    @LogMessage
    @Message(id=2, value = "invalid {0}", format = Message.Format.MESSAGE_FORMAT)
    void test(String dateString);

    // this is a typcial exception 
    @Message(id = 3, value = "Invalid '%s'")
    IllegalArgumentException invalidPermissionAction(String action);
}

}

也有效。所以我假设我可以将日志消息、异常和字符串消息放在 a 中@MessageLogger,并且不需要用@MessageBundle. 我对吗?这种方法是否有任何隐藏的限制?

4

1 回答 1

1

那是对的。您可以将日志消息、字符串消息和异常放在同一个文件中。

于 2021-02-26T17:10:55.427 回答