Message Logger Interfaces
Logger interfaces provide a way to internationalize log messages. A logger interface is an interface annotated with
@MessageLogger. Each method in must be annotated with @Message which will
be used to determine the message to be logged.
The value for a @Message may contain an expression.
| Expressions are in the form of ${key:defaultValue}. If the key is prefixed withsys.a system property is
used. If the key is prefixed withenv.an environment variable is used. In all other cases the properties are resolved
from theorg.jboss.logging.tools.expressionPropertiespath. If the key is not found in the properties the default
value will be used. | 
| Expressions are processed at compile time. The values will be hard-coded in the generated source files. | 
The following constraints are placed on methods in a message logger:
- 
The method must have a voidreturn type
- 
The method must be annotated with @LogMessage
- 
The method must be annotated with @Messageor a message must be inheritable.
- 
A method can have only one @Causeparameter.
| A message is inheritable if the two methods have the same name and same number of format parameters. | 
| A format parameter is a parameter that has no annotations or is annotated with one of the following annotations; @FormatWith,@Posor@Transform. | 
A message logger interface may also extend the org.jboss.logging.BasicLogger. This allows the logging interface to be usable for standard logging. For example AppLogger.LOGGER.debugf("Initializing %s", this);
Example Message Logger
@MessageLogger(projectCode = "CW") (1)
public interface AppLogger extends BasicLogger {
    AppLogger LOGGER = Logger.getMessageLogger(AppLogger.class, AppLogger.class.getPackage().getName());
    @LogMessage
    @Once (2)
    @Message("%s version %d.%d.%d.%s") (3)
    void appVersion(CharSequence name, int major, int minor, int macro, String rel);
    @LogMessage(level = Logger.Level.ERROR) (4)
    @Message(id = 100, value = "Failure while closing %s")
    void closeFailure(@Cause Throwable cause, Object obj);
    @LogMessage(level = Logger.Level.WARN)
    @Message(id = 101, value = "Encoding %s could not be found. Defaulting to %s.")
    void encodingNotFound(String encoding, Charset dft);
    @LogMessage
    @Message(id = 102, value = "Cache size changed to '%d'")
    void cacheSizeChanged(@Transform(Transform.TransformType.SIZE) Collection<String> c);
    @LogMessage
    void cacheSizeChanged(@Transform(Transform.TransformType.SIZE) String... array);
    @LogMessage
    void cacheSizeChanged(@Transform(Transform.TransformType.SIZE) Map<String, Object> map);
}| 1 | The projectCodewill be prepended to messages which have anidspecified. For example withid = 100the message will be prepended withCW000100. You can control the number padding with thelengthproperty on the annotation. | 
| 2 | Ensures the log message is only written once. | 
| 3 | No idis specified for this message which means no id will be prepended on this message. | 
| 4 | Overrides the default level to ERRORto indicate an error message should be logged. |