1 Reply Latest reply: Jun 22, 2013 2:15 AM by René van Wijk RSS

    Weblogic logging implementation

    webyildirim

      Hi experts,

      I m trying to implement org.apache.commons.logging.Log implementation. I copied 2 lib jars into domainhome/lib folder acc to http://docs.oracle.com/cd/E21764_01/web.1111/e13739/config_logs.htm#i1014785. If i use System.setProperty(LogFactory.FACTORY_PROPERTY, "weblogic.logging.commons.LogFactoryImpl"); before creating logger instance (by using LogFactory.getFactory().getInstance(this.getClass());) it works. But i do not want to use setProperty on every class by this way. So i manipulated my setDomainEnv.cmd (see below plz) as adding -Dweblogic.logging.commons.LogFactoryImpl=org.apache.commons.logging.LogFactory argument, i have not faced any exception when i start weblogic by that way but it does not writeout any log.

      Plz help me that what i missed?

      Thx in advance

      Brgds

       

      sertDomainEnv.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");

      ....

      }}

        • 1. Re: Weblogic logging implementation
          René van Wijk

          You have to make sure the commons-logging library is in the system classpath (with the logging implemenation it is using, for example log4j)

           

          To this end you can edit the commEnv file (which is located in the $WL_HOME/common/bin directory) for example,

           

          WEBLOGIC_CLASSPATH="${JAVA_HOME}/lib/tools.jar${CLASSPATHSEP}${WL_HOME}/server/lib/weblogic_sp.jar${CLASSPATHSEP}${WL_HOME}/server/lib/weblogic.jar${CLASSPATHSEP}${FEATURES_DIR}/weblogic.server.modules_12.1.1.0.jar${CLASSPATHSEP}${WL_HOME}/server/lib/webservices.jar${CLASSPATHSEP}${ANT_HOME}/lib/ant-all.jar${CLASSPATHSEP}${ANT_CONTRIB}/lib/ant-contrib.jar${CLASSPATHSEP}${WL_HOME}/common/deployable-libraries/log4j-1.2.13.jar${CLASSPATHSEP}${WL_HOME}/common/deployable-libraries/commons-logging-1.1.1.jar" 

           

          More information is provided here http://middlewaremagic.com/weblogic/?p=6725 (at the end of the post)