简体   繁体   中英

@MessageLogger and @MessageBundle

I use jboss-logging. According to https://jboss-logging.github.io/jboss-logging-tools/#message-bundle-interfaces , there the two types:

  • @MessageLogger for log messages
  • @MessageBundle for exceptions and string messages

I don't know how this is internally handled but using

@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);
}

}

also works. So I assume that I can put log messages, exceptions and string messages within a @MessageLogger and don't need to separate them by @MessageBundle . Am I right? Are there any hidden limitations with this approach?

That is correct. You can put log messages, string messages and exceptions in the same file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM