IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
  • 1.  CAF Application logging using log4j

    Posted Thu September 25, 2008 04:58 AM

    I am working on a CAF application in WM7.1 and my requirement is to log all application specific logs (debug, info, warn, fatal) in a separate application log file. I tried using my own log4j jar & log4.properties file within my CAF application but no information is getting logged (may be ClassLoader issue). I would appreciate all help on configuring logging in 7.1 CAF application using log4j. Some information I am looking are as below

    1. Where to configure logger, appender & layout information. (is it log4j.init.properties file)
    2. API to retrieve logger & log (debug, info, warn & fatal) messages from my CAF application.

    Thanks in advance


    #MWS-CAF-Task-Engine
    #webMethods-BPMS
    #webMethods


  • 2.  RE: CAF Application logging using log4j



  • 3.  RE: CAF Application logging using log4j

    Posted Thu September 25, 2008 10:02 PM

    Thanks Alex for the reply. But I can’t access the link. Even though I am registered with the internal sag forum, I can’t see any forum list. I guess you need to provide me access to the forum.


    #MWS-CAF-Task-Engine
    #webMethods-BPMS
    #webMethods


  • 4.  RE: CAF Application logging using log4j

    Posted Fri September 26, 2008 06:15 PM

    From: Norman, Eric
    Sent: Wednesday, July 02, 2008 11:32 AM
    To: Imel, Mark; RnD-wM-CAF-SWAT
    Subject: RE: Do we have an example of log4j configuration for CAF Standalone apps?

    It


    #webMethods
    #MWS-CAF-Task-Engine
    #webMethods-BPMS


  • 5.  RE: CAF Application logging using log4j

    Posted Sat September 27, 2008 12:19 AM

    Thanks Alex!!
    I made it work by directly adding a named logger to log4j.init.properties file of MWS/server/config folder. It is working as expected (Not sure if it is recommended way…).

    I did put my log4j.jar in WEB-INF/lib folder & log4j.properties in WEB-INF/classes folder in MWS server expecting the application Classloader to load the appropriate file but nothing was getting logged. I will give it a try again.

    Anyways thanks for your prompt response and I really appreciate all your help.


    #webMethods
    #webMethods-BPMS
    #MWS-CAF-Task-Engine


  • 6.  RE: CAF Application logging using log4j

    Posted Wed February 09, 2011 03:57 AM

    Sandeep, did you work out how to do it? Can you please tell me? It’s not working for me.


    #webMethods
    #webMethods-BPMS
    #MWS-CAF-Task-Engine


  • 7.  RE: CAF Application logging using log4j

    Posted Thu February 10, 2011 02:46 PM

    Hi,

        We also use custom loggers for our applications.
    
    A log4j jar file alredy exists by default in [b]webMethods7/common/lib/ext/log4j.jar[/b]. I [b]think [/b]MWS & IS uses this jar.
    
    In order to use a custom logger  for our applications we have made the following configurations:
    
    - in the file [b]MyApp\WebContent\WEB-INF\web.xml[/b] add the following listener:
    
    	<listener>
    <listener>com.myapp.util.MyServletContextListener</listener>
    </listener>
        - create the class [b]com.myapp.util.MyServletContextListener[/b]:
    
    import javax.servlet.ServletContextEvent;
    import javax.servlet.ServletContextListener;
    import org.apache.log4j.PropertyConfigurator;
    
    public class MyServletContextListener implements ServletContextListener {
    
    public void contextDestroyed(ServletContextEvent arg0) {
    // do nothing
    }
    
    public void contextInitialized(ServletContextEvent arg0) {
    try {
    // Set Logggingproperties with Configfile
    PropertyConfigurator.configureAndWatch(arg0.getServletContext().getRealPath(
    "/WEB-INF/" + "myLog4j.properties"),5 * 1000);
    } catch (Exception e) {
    e.printStackTrace();
    }
    
    }
    
    }
       - create your own [b]myLog4j.properties[/b] file
    - use the logger in your application:
    
    private static Logger myLogger = Logger.getLogger(Foo.class);

    br,
    Vlad


    #webMethods-BPMS
    #webMethods
    #MWS-CAF-Task-Engine