The usage of a Logging-Service in Tapestry is quite easy. You just have to use the @Inject Annotation in your classes.
import org.slf4j.Logger;
@Inject
private Logger logger;
A little bit more complicated is the usage in a Tapestry-Service. Here an @Inject Annotation will fail, so you would have to get an instance for your logger from another source. One possibility would be to use a build-method in your Module class. But then, you would have to distribute such method for each service which should use a logger.
Tapestry helps you here and can contribute the needed Logger instance if you insert a constructor method to your service:
import org.slf4j.Logger;
private final Logger logger;
public MyServiceImpl(final Logger _logger){
this.logger = _logger;
this.logger.debug("Successfully initialized MyServiceImpl);
}
Your Service will now be initialized with a working instance of the Logger-class.
The usage of a Logging-Service in Tapestry is quite easy. You just have to use the @Inject Annotation in your classes.
import org.slf4j.Logger;
@Inject
private Logger logger;
A little bit more complicated is the usage in a Tapestry-Service. Here an @Inject Annotation will fail, so you would have to get an instance for your logger from another source. One possibility would be to use a build-method in your Module class. But then, you would have to distribute such method for each service which should use a logger.
Tapestry helps you here and can contribute the needed Logger instance if you insert a constructor method to your service:
import org.slf4j.Logger;
private final Logger logger;
public MyServiceImpl(final Logger _logger){
this.logger = _logger;
this.logger.debug("Successfully initialized MyServiceImpl);
}
Your Service will now be initialized with a working instance of the Logger-class.