本文介绍了如何让google guice注入一个自定义记录器,比如一个commons-logging或log4j logger的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google guice有 。但是,如果我想使用commons-logging或log4j记录器呢?

Google guice has a built-in logger binding. But what if I want to use a commons-logging or log4j logger?

我可以注意注入由

LogFactory.getLog(CLASS.class)

但是具有与内置绑定相同的行为:

But having the same behavior as in built-in binding:






它甚至有意义吗?或者喊我只是使用内置的java Logger?或者只使用没有注射的公共记录?


Does it even makes sense? Or shout I simply use the built-in java Logger? Or just use commons-logging without injections?

推荐答案

页面描述了如何注入一个由它注入的类命名的记录器。

The CustomInjections page on the Guice wiki describes exactly how to inject a logger named by the class it's being injected into.

这篇关于如何让google guice注入一个自定义记录器,比如一个commons-logging或log4j logger的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 15:36