我正在尝试实施org.apache.commons.logging.Log
。我将2个lib jars
复制到符合http://docs.oracle.com/cd/E21764_01/web.1111/e13739/config_logs.htm#i1014785的domainhome/lib
文件夹中。
如果我在创建记录器实例之前使用System.setProperty(LogFactory.FACTORY_PROPERTY, "weblogic.logging.commons.LogFactoryImpl");
(通过使用LogFactory.getFactory().getInstance(this.getClass());
),它可以工作。但我不想通过这种方式在每个班级上使用setProperty
。所以我操纵我的setDomainEnv.cmd
(见下面的PLZ)添加
-Dweblogic.logging.commons.LogFactoryImpl=org.apache.commons.logging.LogFactory
参数,当我以这种方式启动weblogic时,我没有遇到任何异常,但它没有写出任何日志。 Plz帮助我,我错过了什么? Thx提前 Brgds
setDomainEnv.cmd
...
set EXTRA_JAVA_PROPERTIES=-Dweblogic.logging.commons.LogFactoryImpl=org.apache.commons.logging.LogFactory %EXTRA_JAVA_PROPERTIES%
...
MainManagerBean.class
@Stateless(name="MainManager", mappedName = "MainManager")
@TransactionManagement(TransactionManagementType.CONTAINER)
@Interceptors(value = { PerformanceMonitor.class, ProfileInterceptor.class })
public class MainManagerBean implements MainManager, MainManagerLocal
{
private Log logger =LogFactory.getFactory().getInstance(this.getClass());
@PersistenceContext(unitName = "EJBModel")
private EntityManager manager;
@Resource
SessionContext ctx;
@PostConstruct
public void initialized()
{
//System.setProperty(LogFactory.FACTORY_PROPERTY, "weblogic.logging.commons.LogFactoryImpl");
// logger= LogFactory.getFactory().getInstance(this.getClass());
logger.debug("MainManagerBean is initialized");
logger.info("MainManagerBean is initialized");
logger.trace("MainManagerBean is initialized");
....}}
答案 0 :(得分:1)
您的日志工厂属性已反转。你把它显示为:
-Dweblogic.logging.commons.LogFactoryImpl=org.apache.commons.logging.LogFactory
应该是:
-Dorg.apache.commons.logging.LogFactory=weblogic.logging.commons.LogFactoryImpl
http://docs.oracle.com/cd/E11036_01/wlevs20/config_server/logging.html