1
我的項目在Wicket + Spring + JPA/Hibernate上運行。當我使用命令運行它:如何使Jetty打印日誌
mvn jetty:run
我想碼頭打印日誌,我在代碼中。例如,我已經實現了以下DAO:
@Repository(value = "isinDao")
public class IsinDaoJpa implements IsinDao {
@PersistenceContext
private EntityManager em;
private static Logger logger = LoggerFactory.getLogger(IsinDaoJpa.class);
public Isin findById(Long id) {
return em.find(Isin.class, id);
}
public List findAll() {
Query query = em.createQuery("select e from Isin e");
logger.info("DAO: All ISINs selected");
return query.getResultList();
}
}
我該如何讓Jetty實時將這些信息打印到命令行窗口中?
在pom.xml中,我有以下的依存關係:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>