|
||||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||||||
See:
Description
| Class Summary | |
|---|---|
| Logger | A Logger implementation that forwards all calls to the #delegate(). |
| Enum Summary | |
|---|---|
| Logger.Level | Levels used by this logging API. |
| Annotation Types Summary | |
|---|---|
| Category | Specifies a string category for the injected logger. |
| Log | A typed logger method. |
| LoggingClass | Mark a parameter as specifying the name of the logging class to use. |
| MessageLogger | Signify that an interface is a typed logger interface. |
| Suffix | A suffix to use on the specified category (or fully qualified name of the injection point type if no category is specified). |
| TypedCategory | Specifies a typed category for the injected logger. |
Solder integrates with JBoss Logging 3 to provide injectable native loggers or typed message loggers (suitable for internationalization and localization) while still offering a choice of logging backend
Solder builds on its typed message bundles support combined with JBoss Logging 3 to provide the following feature set:
To define a typed message logger, first create an annotated interface with methods configured as log commands. The log messages to use printf-style interpolations of parameters (%s).
@MessageLogger
public interface TrainSpotterLog {
@Log @Message("Spotted %s diesel trains")
void dieselTrainsSpotted(int number);
}
You can then inject the typed logger with no further configuration necessary. You use another annotation to set the category of the logger to "trains" at the injection point:
@Inject @Category("trains") TrainSpotterLog log;
You log a message by simply invoking a method of the message logger interface:
log.dieselTrainsSpotted(7);
The default locale will be used unless overridden. Here we configure the logger to use the UK locale.
@Inject @Category("trains") @Locale("en_GB") TrainSpotterLog log;
You can also log exceptions:
@MessageLogger
public interface TrainSpotterLog {
@Log @Message("Failed to spot train %s")
void missedTrain(String trainNumber, @Cause Exception exception);
}
You can then log a message with exception:
log.missedTrain("RH1", cause);
You can also inject a native Logger from the JBoss Logging 3 API:
@Inject Logger log;
Log,
Category,
TypedCategory,
org.jboss.solder.logging..Suffix,
Cause,
Message,
Locale,
Formatter
|
||||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||||||