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.  How to write custom logs in CAF Portlet Applications

    Posted Wed July 18, 2012 09:59 AM

    Hi All,

    Iam new to this forum and also to webMethods.

    We have MWS 8.2 and IS. In my CAF application portlet, i want to write customized logs using log4j or any other in a separate log file.

    kindly provide guidelines, sample code…

    regards,
    Lakshmi.P


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


  • 2.  RE: How to write custom logs in CAF Portlet Applications

    Posted Wed July 18, 2012 02:10 PM

    Portlets deployed to MWS can use several different logging APIs. You can use whichever one you prefer.

    For example:

    
    //logging via log4j APIs    
    org.apache.log4j.Logger log4jLogger = org.apache.log4j.Logger.getLogger(getClass());
    log4jLogger.info("Log Message from org.apache.log4j.Logger");
    
    //logging via java built in logging APIs
    java.util.logging.Logger juliLogger = java.util.logging.Logger.getLogger(getClass().getName());
    juliLogger.info("Log Message from java.util.Logger");
    
    //logging via apache commons logger
    org.apache.commons.logging.Log oacLogger = org.apache.commons.logging.LogFactory.getLog(getClass());
    oacLogger.info("Log Message from org.apache.commons.logging.Log");
    
    //logging via the slf4j logging facade
    org.slf4j.Logger slf4jLogger = org.slf4j.LoggerFactory.getLogger(getClass());
    slf4jLogger.info("Log Message from org.slf4j.Logger");

    The log messages for all of the above logging apis will displayed in the console and recorded in the MWS full.log


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


  • 3.  RE: How to write custom logs in CAF Portlet Applications

    Posted Thu July 19, 2012 04:33 AM

    thanks for your reply eric !

    actually i want to write logs in my <custom_log_file>.log not in MWS default _full_log

    can i add log4j.jar, log4j.properties in My CAF Portlet Application Project and use it to write custom logs.

    or else should i have to use in-built log4j.jar in MWS. i think in-built jar only supports logs to write logs in _full_log file, server.log files.

    kindly suggest !!!


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


  • 4.  RE: How to write custom logs in CAF Portlet Applications

    Posted Thu July 19, 2012 01:37 PM

    the log4j.jar provided by MWS should be fine, you don’t need another copy of that.

    Since CAF applications are web applications, you can use the techniques for initializing log4j in a servlet or context listener.

    For an example, see:
    [url]http://blog.idleworx.com/2010/01/setting-up-log4j-for-simple-java-web.html[/url]

    your log4j.properties file content would just need to define the appender and declare what log categories go to the appender.

    For example, something like this:

    
    # your category
    log4j.category.yourLogCategory=INFO, yourCustomFile
    log4j.additivity.yourLogCategory=true
    
    # appender
    log4j.appender.yourCustomFile=com.webmethods.rtl.logging.CollectorFileAppender
    log4j.appender.yourCustomFile.File=${log4j.logging.dir}/yourLogFileName.log
    log4j.appender.yourCustomFile.threshold=${log4j.default.log.level}
    log4j.appender.yourCustomFile.Append=true

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


  • 5.  RE: How to write custom logs in CAF Portlet Applications

    Posted Tue April 07, 2015 03:34 AM

    Hi all,
    I am not able to get log details from CAF UI page which is logged for testing
    Have used

    org.apache.log4j.Logger log4jLogger = org.apache.log4j.Logger.getLogger(getClass());
    log4jLogger.info("Log Message from org.apache.log4j.Logger");
    or 
    
    System.out.println("Test Log");

    But none of the log is appearing in any log file.
    Please let me know if there is any alternate way to get the intermediate value printed in log file for testing.

    Wm Version:9.7
    OS:Windows

    Thanks
    Baharul


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


  • 6.  RE: How to write custom logs in CAF Portlet Applications

    Posted Tue April 07, 2015 02:33 PM

    Your log4j example looks correct to me. That log message would be written to the MWS full.log unless the administrator has configured the logging level for that appender to a level that is higher than ‘info’.

    The System.out.println call would only write the message to the console window, it would not get routed to the MWS log file.


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


  • 7.  RE: How to write custom logs in CAF Portlet Applications

    Posted Sun January 31, 2016 08:27 AM