SeamFramework.orgCommunity Documentation
These modules are usable on any JSR-299 implementation, not just Weld!
Adding logging to your application is now even easier with simple injection of a logger object into any CDI
bean. Simply create an injection point of type org.slf4j.Logger
and an appropriate logger
object will be injected into any instance of the bean.
import org.slf4j.Logger;
import javax.inject.Inject;
public class Checkout {
private @Inject Logger log;
public void invoiceItems() {
ShoppingCart cart;
...
log.debug("Items invoiced for {}", cart);
}
}
The example shows how objects can be interpolated into a message. If you use this approach, you do not need
to surround a call to the logger with a condition like if ( log.isDebugEnabled() )
to
avoid string concatenation.
You can add Weld logging to your project by including weld-logger.jar, sl4j-api.jar and sl4j-jdk14.jar to
your project. Alternatively, express a dependency on the org.jboss.weld:weld-logger
Maven artifact.
If you are using Weld as your JSR-299 implementation, there's no need to include sl4j as it's already included (and used internally).