Package org.jboss.solder.logging

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

See: Description

Package org.jboss.solder.logging Description

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;
 
See Also:
Log, Category, TypedCategory, org.jboss.solder.logging..Suffix, Cause, Message, Locale, Formatter

Copyright © 2012 Seam Framework. All Rights Reserved.