See: Description
| Class | Description |
|---|---|
| Logger |
A Logger implementation that forwards all calls to the
#delegate(). |
| Enum | Description |
|---|---|
| Logger.Level |
Levels used by this logging API.
|
| Annotation Type | Description |
|---|---|
| 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 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;
Copyright © 2012 Seam Framework. All Rights Reserved.