2013-06-19 102 views
0

我試圖執行org.apache.commons.logging.Log實現。我將2 lib jars複製到domainhome/lib文件夾根據http://docs.oracle.com/cd/E21764_01/web.1111/e13739/config_logs.htm#i1014785Weblogic 10.3日誌執行

如果我在創建記錄器實例(使用LogFactory.getFactory().getInstance(this.getClass());)之前使用System.setProperty(LogFactory.FACTORY_PROPERTY, "weblogic.logging.commons.LogFactoryImpl");,它將起作用。但是我不想用這種方式在每個班上使用setProperty。所以我操作我setDomainEnv.cmd(見下文PLZ)如添加

-Dweblogic.logging.commons.LogFactoryImpl=org.apache.commons.logging.LogFactory

的說法,我還沒有遇到任何異常,當我通過這種方式啓動WebLogic但它並不WriteOut的任何記錄。 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

http://buttso.blogspot.de/2011/06/using-slf4j-with-weblogic- server.html – Cris

回答

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

+0

更改acc這個信息,這有效。非常感謝。但是這導致了一個我無法理解的新問題。有了這個conf,當試圖通過瀏覽器到達wl管理控制檯時,會拋出 webyildirim

+1

不知道爲什麼會發生這種情況,但也許你可以試試'-Dorg.apache.commons。 logging.LogFactory = org.apache.commons.logging.impl.LogFactoryImpl',或者看看這裏的答案是否有助於https://forums.oracle.com/thread/1078003 –