I’m using the Logger class in my module to schedule some tasks but nothing is shown in my console.
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class Task {
private final ActorSystem actorSystem;
private final ExecutionContext executionContext;
private final Logger log;
@Inject
public Task(ActorSystem actorSystem, ExecutionContext executionContext) {
this.actorSystem = actorSystem;
this.executionContext = executionContext;
this.log = LoggerFactory.getLogger(getClass());
this.init();
}
private void init() {
actorSystem.scheduler().schedule(
Duration.create(5, TimeUnit.SECONDS),
Duration.create(5, TimeUnit.SECONDS),
this::doTask,
executionContext
);
}
private void doTask() {
log.info("Do my task.");
}
}
public class MyModule extends AbstractModule {
@Override
protected void configure() {
bind(Task.class).asEagerSingleton();
}
}
If I replace the log.info() call by a System.out.println() I can see that the task is run.