webMethods

webMethods

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.

 View Only
Expand all | Collapse all

Use log4j2 in webmethods

  • 1.  Use log4j2 in webmethods

    Posted Tue November 10, 2015 05:36 AM

    I want to use log4j2 in webMethods project and i have write some code. it’s a beta version.
    you can configure log4j2.xml file in the Log4j2 package home page.

    ----20151118 added shutdown service.
    Log4j2.zip (999 KB)


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 2.  RE: Use log4j2 in webmethods

    Posted Tue November 10, 2015 01:47 PM

    Thanks for your time and efforts. I will check this and let you know if I have any questions.

    Can you please attach the code sample at the below location with some instruction guide. It will help the forum members:

    http://techcommunity.softwareag.com/ecosystem/communities/public/webmethods/contents/codesamples/


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 3.  RE: Use log4j2 in webmethods

    Posted Mon January 27, 2020 03:57 AM

    Hi,
    this doesn’t seem working on 10.x versions.
    I tried couple of combinations but none seem to work so far with out interfering with IS’ logging framework.

    has any one else encountered the same issue


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 4.  RE: Use log4j2 in webmethods

    Posted Wed March 10, 2021 03:46 AM

    Hi Chakradhar, I am facing the same issue with 10.5. did you get any resolution? please share if you resolved it :slight_smile:

    much appriciated


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 5.  RE: Use log4j2 in webmethods

    Posted Thu March 11, 2021 02:42 PM

    Hi Sridhar,
    I’m assuming your Log4j2 config file is not getting loaded in 10.5. Unlike prior versions, webMethods Integration Server 10.5 comes with Log4j2 and is used for Integration Server’s logging as well. As part of it’s Logj42 use, IntegrationServer configures <sag dir>/profiles/IS_<instance>/configuration/logging/lo4j2.properties as the Log4j2 configuration file by adding the following two lines in the <profile_dir>/configuration/wrapper.conf file:

    wrapper.java.additional.4=-Dlog4j.configurationFile="<sag dir>\profiles\IS_default/configuration/logging/log4j2.properties"
    wrapper.java.additional.4.stripquotes=TRUE
    

    Because such an entry already presents on the Integration Server, the log4j2.xml from your custom application may not be loading. You can fix it by adding your Logj42 configuration file to the above parameter as shown below:

    -Dlog4j.configurationFile="<sag dir>\profiles\IS_default/configuration/logging/log4j2.properties,packages/<your-logging-pkg>/config/Log4j2.xml"

    Here, I’m using relative path i.e. “packages/…” because the current working directory of any Integration Server is <sag dir>/IntegrationServer/instances/<instance_name> and typically the configuration stays in custom packages so I’m showing that as sample. If you have it in another folder, please specify the path to that file. Also, if you have multiple Log4j2 configuraiton files, you can add them to the same parameter using , (comma) as the separator.

    We don’t recommend changing wrapper.conf so what we recommend here is to move the whole entry to custom_wrapper.conf to the next available 3xx entry e.g. 304, 305 and etc. Here, I’m choosing 304 because that’s my next available 3xx entry on 10.5.

    wrapper.java.additional.304="<sag dir>\profiles\IS_default/configuration/logging/log4j2.properties,packages/<your-logging-pkg>/config/Log4j2.xml"
    wrapper.java.additional.304.stripquotes=TRUE
    

    Please let us know how it works out.

    Thanks,
    -Senthil


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 6.  RE: Use log4j2 in webmethods

    Posted Thu March 25, 2021 12:30 AM

    Hi Senthil, I have tried what you suggested and it does not work for me. Please can you kindly take a look below and let me know what’s wrong? I need help.

    1. Here is my custom_wrapper.conf from the directory C:\SoftwareAG\profiles\IS_default\configuration

    #encoding=UTF-8
    wrapper.app.parameter.2=4
    wrapper.app.parameter.5=-service
    wrapper.app.parameter.6=sagis105_1.default
    wrapper.java.additional.100=-server
    wrapper.java.additional.101=-Dorg.apache.xml.dtm.DTMManager=org.apache.xml.dtm.ref.DTMManagerDefault
    wrapper.java.additional.102=-Djavax.xml.xpath.XPathFactory:Oracle Java Technologies | Oracle
    wrapper.java.additional.103=-Dcom.webMethods.sc.auditing.Use80TableFormat=true
    wrapper.java.additional.104=-Dsun.lang.ClassLoader.allowArraySyntax=true
    wrapper.java.additional.201=-DWM_HOME=C:\SoftwareAG
    wrapper.java.additional.202=-Dwatt.server.prepend.classes=C:\SoftwareAG\common\lib\wm-converters.jar
    wrapper.java.additional.203=-Dwatt.server.append.classes=
    wrapper.java.additional.204=-Dlog4j.configuration=“C:\SoftwareAG\IntegrationServer\instances\default\log4j.properties,esb.log4j2.xml”
    wrapper.java.additional.204.stripquotes=TRUE
    wrapper.java.additional.301=-Dorg.tanukisoftware.wrapper.WrapperStartStopApp.passthroughMode=START
    wrapper.java.additional.302=-Djava.awt.headless=true
    wrapper.java.additional.303=-DLog4jContextSelector=org.apache.logging.log4j.core.selector.BasicContextSelector
    wrapper.java.classpath.3=C:\SoftwareAG\common\lib\wm-converters.jar
    wrapper.java.initmemory=256
    wrapper.java.library.path.11=C:\SoftwareAG\IntegrationServer\instances\default\lib
    wrapper.java.library.path.12=C:\SoftwareAG\IntegrationServer\instances\default\support\win32
    wrapper.java.library.path.13=C:\SoftwareAG\common\bin
    wrapper.java.library.path.append_system_path=TRUE
    wrapper.java.maxmemory=1024
    wrapper.jvm_exit.timeout=300
    wrapper.on_exit.42=RESTART
    wrapper.ping.timeout=300
    wrapper.restart.reload_configuration=TRUE
    wrapper.shutdown.timeout=300
    wrapper.single_invocation=TRUE
    wrapper.working.dir=C:\SoftwareAG\IntegrationServer\instances\default

    1. Here is my Log4j2 configuration file (esb.log4j2.xml) as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <Configuration>
    <Appenders>
    <File name="File" FileName="logs\esb.log">
    <PatternLayout>
    <pattern>
    [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} %msg%n 
    </pattern>
    </PatternLayout>
    </File>
    </Appenders>
    <Loggers>
    <Logger name="MyLogger" level="debug" additivity="false">
    <AppenderRef ref="File"/>
    </Logger>
    </Loggers>
    </Configuration>
    
    1. Here is my custom java service (just the part that calls the Logger) that I run from inside the webMethods runtime, and it’s a custom java code in one of my wM IS packages, as follows:

       	Logger logger = LogManager.getLogger("MyLogger");
      
      try {
      if(logger.isEnabled(level)) {
      
      // remove variable substitutions from the inputs and trim to max length
      message = removeVarSubstitutions(message, 1999);
      
      /* append to logger */
      logger.log(level, message, callingServiceName);	
      

    Question: what is wrong with the custom_wrapper.conf, and how can I call the Logger named “MyLogger” as defined in my Log4j2 configuration file (esb.log4j2.xml) from the java service above?

    Results: every time my java service logs any messages, it goes to the wrapper.log located under the directory \profiles\IS_default/logs, instead of using the Logger “MyLogger” configuration as shown in the configuration file (esb.log4j2.xml) listed above.

    So the Logger configuration is not working and by default it goes to the webMethods Integration Server console file (aka wrapper.log)

    Btw, I am running webMethods Integration v10.5 on Windows Server 2012 and using MS SQL database.

    Please advise.

    Thanks in advance.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 7.  RE: Use log4j2 in webmethods

    Posted Fri June 25, 2021 07:58 AM

    Hi Senthil,

    I tried the options in this thread. but seeing some unexpected results on my side (IS v10.7.0.0).
    The log4j log file is getting created as per config but only 1 entry related to MWS is getting logged upon IS restart.
    All custom entries are still going to the wrapper.log
    Attaching the config and log files (wrapper.conf is untouched, I included log4j path in custom_wrapper.conf as suggested in this thread).
    Thank you in adavnce
    custom_wrapper.conf (2.1 KB)
    log4j2.xml (920 Bytes)
    rolling-file.log (97 Bytes)
    wrapper.conf (10.2 KB)
    wrapper.log (818.7 KB)


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 8.  RE: Use log4j2 in webmethods

    Posted Fri June 25, 2021 01:24 PM

    Hi,

    Just to update, the option with custom_wrapper.conf didn’t work out for me even with SPM and machine restart.
    With the use of package class loader, it’s working for me.
    package class loader


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 9.  RE: Use log4j2 in webmethods

    Posted Fri November 19, 2021 09:45 AM

    Hi Senthil,
    Please clarify on this. If we are adding new log4j config entry in custom_wrapper.conf. do we need to move the existing predefined entry in wrapper.conf also to custom_wrapper.conf. because I use 10.5 and it has a default entry in wrapper.conf and when I add a new config file entry in custom_wrapper.conf. it’s not getting loaded. I have verified in wrapper.log
    wrapper.conf:
    wrapper.java.additional.4=-Dlog4j.configurationFile=“/webMethods/webmethods600/profiles/IS_default/configuration/logging/log4j2.properties”
    wrapper.java.additional.4.stripquotes=TRUE
    custom_wrapper.conf:
    wrapper.java.additional.204=-Dlog4j.configuration=“/webMethods/webmethods600/appProperties/Log4j2Demo.xml”
    wrapper.java.additional.204.stripquotes=TRUE

    I could not see even the log4j2.properties getting loaded in wrapper.log

    Thanks in Advance!
    Vignesh


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 10.  RE: Use log4j2 in webmethods

    Posted Sat December 04, 2021 03:01 PM

    Hi @vignesh.govindhan,
    Sorry for the delayed response. Have you seen @Christoph_Jahn’s post about using a custom package to configure Log4j2 loggers? If not, please see Jahn’s Sep 23rd comment: https://community.ibm.com/community/user/integration/discussion/use-log4j2-in-webmethods#bmef63d0ca-da52-444f-9a71-5b2b1c763696.
    As for your questions here, custom_wrapper.conf is used to add new JVM properties and to overwrite anything previously defined by the wrapper.conf.
    If you add a same property with a different value in custom_wrapper.conf, it will overwrite what is defined in the wrapper.conf. If you want to amend your config, then copy over the value of that property from wrapper.conf and then combine it with your value to avoid losing the wrapper.conf value of this property. If you are adding your log4j2 config file then you can bring over the value from wrapper.conf and then add a comma (,) and specify your file. You can find examples of this in this thread.
    Also, the -Dlog4j.configurationFile is the system property used by Log4j2. In your example, you were using -Dlog4j.configuration, which is different property and it was only used in Log4j1 as far as I know.

    But if you follow Jahn’s https://github.com/SoftwareAG/webmethods-integrationserver-log4jdemo, it will be upgrade prone and easy to maintain.


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 11.  RE: Use log4j2 in webmethods

    Posted Sat December 04, 2021 03:23 PM

    Thanks for your response. I will follow the thread you have mentioned.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 12.  RE: Use log4j2 in webmethods

    Posted Mon January 27, 2020 05:26 AM

    Hi Chakradhar,

    please provide some details what exactly you have tried and what was the outcome.

    As per the age of the thread you might have missed out the change in the directory structure in wM 9.6, where the IS not working under IntegrationServer directly but uses IntegrationServer/instances/default nowadays to support multiple instances being created from installation directory, while in previous versions this always required different installation directories.

    Regards,
    Holger


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 13.  RE: Use log4j2 in webmethods

    Posted Thu March 25, 2021 05:28 AM

    Hi Waldes,

    Looks like your esb.log4j2.xml is not loaded.
    Evtl. you need to specify the full path to the esb.log4j2.xml as it is already done for the internal log4j.properties file.

    Regards,
    Holger


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 14.  RE: Use log4j2 in webmethods

    Posted Thu March 25, 2021 09:18 AM

    Hi Holder, yes I changed the custom_wrapper.conf file located under C:\SoftwareAG\profiles\IS_default\configuration and added the full path, as you can see below, but the issue is still the same.

    New: I modified the following line in custom_wrapper.conf: (here is the original entry from the custom_wrapper.conf file shipped with the webMethods Integration Server:

    wrapper.java.additional.204=-Dlog4j.configuration=“C:\SoftwareAG\IntegrationServer\instances\default\log4j.properties,C:\SoftwareAG\IntegrationServer\instances\default\config\esb.log4j2.xml”
    wrapper.java.additional.204.stripquotes=TRUE

    Notes:

    • I have replaced the original line that came in the custom_wrapper.conf: and it used to look like the following (but this line was deleted from this file, but I kept a copy):
      wrapper.java.additional.204=-Dlog4j.configuration=file:///C:\SoftwareAG\IntegrationServer\instances\default\log4j.properties

    Question: I wonder what could be wrong? Is the issue with the custom_wrapper.conf file configuration (see above), or is my java service the way the Logger is instantiated (the Logger name is “MyLogger”) and maybe the way the method is invoked inside my java service?

    Please advise.


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 15.  RE: Use log4j2 in webmethods

    Posted Thu March 25, 2021 10:08 AM

    Hi Waldes,
    Your custom wrapper entry appears to be fine. While we are on this subject, I want to mention that you could use relative file reference to identify your config file. In each IS, the top level IS folder is the working directory. In your case, it is C:\SoftwareAG\IntegrationServer\instances\default. You could also just specify it as config\esb.log4j2.xml.

    After making this change, you need to restart the Integration Server. Did you restart? If you did, maybe then the esb.log4j2.xml has some issues. Can you please share that file?

    Thanks,
    -Senthil


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 16.  RE: Use log4j2 in webmethods

    Posted Thu March 25, 2021 10:16 AM

    Hi Waldes,
    I just realized that you have already shared all the details in your initial post. Let me go through it and let you know.

    Thanks,
    -Senthil


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 17.  RE: Use log4j2 in webmethods

    Posted Thu March 25, 2021 11:07 AM

    Hi Sentil, yes I already tried the relative path (config\esb.log4j2.xml) in the custom_wrapper.conf and also the absolute path (as per my previous post).
    Additionally, yes I shutdown the webMethods IS every time and then change the custom_wrapper.conf file and after that I startup the server using the script “startup.bat” located under c:/sag dir/profiles/IS_default/bin.

    Also keep in mind that I am running the webMethods IS on a Windows machine, as indicated in previous post.

    Current results: my java service and the call to the Logger (in this case is “MyLogger” as you can see in previous posts my java service source code) are actually going to the webMethods Integration Server default wrapper.log (located under c:/sag dir/profiles/IS_default/logs), instead of using what is configured in my custom Log4j2 configuration file (config\esb.log4j2.xml).

    I look froward to hearing from you.

    Thanks in advance.


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 18.  RE: Use log4j2 in webmethods

    Posted Thu March 25, 2021 02:00 PM

    Hi Waldes,
    Thanks. I also tried with your config file and after starting up my IS, it created the esb.log file in the \logs folder because that’s what we specified in the configuration file.

    Then I tried to log a message using my own code and it worked. As I didn’t have all the code you are using, I didn’t try that but I don’t think the code is the problem but if you share the full logic of that service, we can try to see if anything can attribute from there.

    As for using the relative path, if your esb.log2.xml exists under C:\SoftwareAG\IntegrationServer\instances\default\config folder, then using config\esb.log4j2.xml should work.

    As a next step, please try to enable Log4j2’s logger to help troubleshoot why it’s not working. In order to do that, edit your esb.log4j2.xml and replace the line <Configuration> with <Configuration status="trace" name="esb">. Then restart the IS. As the IS starts up, you can see the log messages in c:/sag dir/profiles/IS_default/logs/wrapper.log and search for your file esb.log4j2.xml to see if there is any clue.

    Thanks,
    -Senthil


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 19.  RE: Use log4j2 in webmethods

    Posted Thu March 25, 2021 02:26 PM

    Senthil, in order to save time and to avoid impacting you with more work, please can you share here the following files from your webMethods installation:

    • wrapper.conf - from directory C:\SoftwareAG\profiles\IS_default\configuration
    • custom_wrapper.conf - from directory C:\SoftwareAG\profiles\IS_default\configuration
    • java service (the service you mentioned you wrote to test the Logger) - I assume you wrote it as a regular webMethods java service using wM Designer right?

    I would like to compare on my end and verify if there’s anything you have that I don’t have in my webMethods instance, ok?

    I want to make sure I can reproduce your results on my end as well.

    Thanks in advance,
    Waldes


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 20.  RE: Use log4j2 in webmethods

    Posted Thu March 25, 2021 02:36 PM

    custom_wrapper.conf (2.3 KB) wrapper.conf (10.2 KB)
    Hi Waldes,
    Please find my wrapper and custom_wrapper.conf files attached. Also note that my config files have another customer’s log4j2 config file as well from sometime back. I don’t think having that or not having that changes the result.
    Given below is the code I have in a java service named logMessage:

    		IDataMap pipe = new IDataMap(pipeline);
    String loggerName = pipe.getAsString("loggerName");
    String logMessage = pipe.getAsString("logMessage");
    try
    {
    Logger logger = LogManager.getLogger(loggerName);
    logger.fatal(logMessage);
    logger.error(logMessage);
    logger.warn(logMessage);
    logger.info(logMessage);
    logger.debug(logMessage);
    logger.trace(logMessage);
    
    } catch( Throwable t) {
    throw new ServiceException(t);
    }
    

    The following imports are needed to use this code:

    import org.apache.logging.log4j.LogManager;
    import org.apache.logging.log4j.Logger;
    import com.softwareag.util.IDataMap;
    

    Hope this helps.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 21.  RE: Use log4j2 in webmethods

    Posted Thu March 25, 2021 02:42 PM

    logging.java (1.4 KB)
    Hi Waldes,
    I just realized, I only had one IS java service on that folder so sharing that java file (logging.java) as well.


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 22.  RE: Use log4j2 in webmethods

    Posted Wed December 01, 2021 08:15 AM

    Hi Senthil,

    Can you please share your initialization service which loads your config file.


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 23.  RE: Use log4j2 in webmethods

    Posted Sat December 04, 2021 03:27 PM

    Hi @Thiagarajan_Muthulingam2,
    In the previous approaches, I wasn’t using any initialization service. The initialization was done by the log configuration defined by the system property -Dlog4j.configurationFile. But you could follow Jahn’s GitHub - SoftwareAG/webmethods-integrationserver-log4jdemo: Demo for custom logging with Log4J v2 in Integration Server (incl. v10.5+) for a package level Log4j2 configuration/initialization.


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 24.  RE: Use log4j2 in webmethods

    Posted Wed December 08, 2021 09:41 PM

    Hi Senthil,

    Thank you very much for the inputs. In case of Jahn’s sample he has used log4j2.xml, our previous versions of IS were using log4j.properties. I had modified Jahn’s service for loading log4j2.properties and was able to create the log files. However was not able to write message, to do so, i had to modify the custom_wrapper config file as you suggested.

    In addition, i have also added monitorInterval property for my subsequent loggerkeys to work without any manual intervention.

    Thanks!


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 25.  RE: Use log4j2 in webmethods

    Posted Fri December 10, 2021 01:36 AM

    Thanks @Thiagarajan_Muthulingam2. Very kind of you to share your experiences and solution. Much appreciated.

    Sometime back while working with a consultant, I also noticed that when .properties type config file used, the configuration API calls doesn’t work but same configuration and API works if we use .xml type config file. That was strange but we all didn’t have much time to dig deeper and the consultant was ok to leave it as .xml so we left it. @Christoph_Jahn or anyone else, if you had a chance to try with properties type config file with Jahn’s package solution, please share any additional information you have.


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 26.  RE: Use log4j2 in webmethods

    Posted Thu March 25, 2021 08:21 PM

    Senthil, no matter what I do any messages written using the Lo4j2 only go to the wrapper.log and not to the custom esb.log declared in the Log4j2 configuration (xml) file.

    One observation: even if I delete the esb.log file, when the webMethods Integration Server is restarted, a new esb.log file is created with zero bytes (empty file), which indicates that the configuration seems to be having some effect, but for some reason the logger “MyLogger” is not completely activated or the configuration is somewhat overwritten or canceled by the server, and any message written to the logs via my java services goes to the wrapper.log as mentioned above.

    I hope you can take another look in the details below (modified to simplify my configuration a bit) and let me know what you think? What could be causing this? Please, advise.

    I made some minor adjustments to simplify the configuration and I moved the Log4J2 xml configuration file to be located under the wM IS package, in order to match your configuration, instead of putting under the /instances/default/config main directory - this was the biggest change compared to before.

    I also needed to update my custom_wrapper.conf file to reflect this, and I decided to also simplify my Log4J2 xml configuration file, as you can see below:

    1. Here is my custom_wrapper.conf updated, but only the lines relevant to this topic - please note the entries starting with “wrapper.java.additional.205” which match your configuration, as follows:

    wrapper.java.additional.204=-Dlog4j.configuration=file:///C:\SoftwareAG\IntegrationServer\instances\default\log4j.properties
    wrapper.java.additional.205=-Dlog4j.configurationFile=“C:\SoftwareAG\profiles\IS_default/configuration/logging/log4j2.properties,packages/MyISPackage/config/esb.log4j2.xml”
    wrapper.java.additional.205.stripquotes=TRUE

    2. Here is my modified and simplified Log4j2 file (esb.log4j2.xml)

    <?xml version="1.0" encoding="UTF-8"?>
    <Configuration status="DEBUG">
    <Appenders>
    <File name="LogToFile" FileName="esb_new.log">
    <PatternLayout>
    <Pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} %msg%n</Pattern>
    </PatternLayout>
    </File>
    </Appenders>
    <Loggers>
    <Logger name="MyLogger" level="error" additivity="false">
    <AppenderRef ref="LogToFile"/>
    </Logger>
    </Loggers>
    </Configuration>
    

    3. Here is my java service now in a new simplified version:

    package POC.LMLogging;
    
    import com.wm.data.*;
    import com.wm.util.Values;
    import com.wm.app.b2b.server.Service;
    import com.wm.app.b2b.server.ServiceException;
    import org.apache.logging.log4j.LogManager;
    import org.apache.logging.log4j.Logger;
    
    public final class logMessage_SVC
    
    {
    
    /** 
    * The primary method for the Java service
    *
    * @param pipeline
    *            The IData pipeline
    * @throws ServiceException
    */
    public static final void logMessage(IData pipeline) throws ServiceException {
    // pipeline
    IDataCursor pipelineCursor = pipeline.getCursor();
    String	logMessage = IDataUtil.getString( pipelineCursor, "logMessage" );
    pipelineCursor.destroy();
    
    String loggerName = "MyLogger";
    
    // pipeline
    try
    {
    Logger logger = LogManager.getLogger(loggerName);
    logger.fatal(logMessage);
    logger.error(logMessage);
    logger.warn(logMessage);
    logger.info(logMessage);
    logger.debug(logMessage);
    logger.trace(logMessage);
    
    } catch( Throwable t) {
    throw new ServiceException(t);
    }
    
    
    }
    
    // --- <<IS-BEGIN-SHARED-SOURCE-AREA>> ---
    
    
    
    // --- <<IS-END-SHARED-SOURCE-AREA>> ---
    
    final static logMessage_SVC _instance = new logMessage_SVC();
    
    static logMessage_SVC _newInstance() { return new logMessage_SVC(); }
    
    static logMessage_SVC _cast(Object o) { return (logMessage_SVC)o; }
    
    }
    

    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 27.  RE: Use log4j2 in webmethods

    Posted Fri March 26, 2021 01:36 PM

    Hi Wales,
    Do you see esb.log getting created? I still think your config file is not loading. Can you please share zip of your wrapper.log file? Please try to restart the server and then pull the log after IS startup completes that way, the log will be clean for this purpose.


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 28.  RE: Use log4j2 in webmethods

    Posted Mon April 05, 2021 11:51 AM

    Hi @Senthil, yes it worked as you suggested. My webMethods Integration Server installation had another java dependancy that was impacting the class loader, and once I installed a new IS instance from scratch, it all worked as expected. The issue has been resolved. Thanks for your help and guidance in this topic.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 29.  RE: Use log4j2 in webmethods

    Posted Mon April 05, 2021 01:23 PM

    Hi Waldes,
    That’s great news! Thanks so much for updating us.


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 30.  RE: Use log4j2 in webmethods

    Posted Thu December 02, 2021 02:50 AM

    Hi Waldes,

    Can you please share what was causing the issue. What was the java dependency you are referring here.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 31.  RE: Use log4j2 in webmethods

    Posted Thu December 02, 2021 12:27 PM

    Hi,

    If I remember right it was the recommendation to remove all custom log4j2.jars from the code as the IS already contains one in its common libs.

    When there are multiple (maybe different) versions of a particular jar in the classpath, you might encounter class loading issues.

    Regards,
    Holger


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 32.  RE: Use log4j2 in webmethods

    Posted Wed December 08, 2021 09:23 PM


  • 33.  RE: Use log4j2 in webmethods

    Posted Sat April 17, 2021 01:18 AM

    Hi Waldes, So what did you exactly do to solve the issue? I am also facing the same issue of log file not getting generated. I did read all the comments in this thread but, still the issue doesn’t seem to get resolved for me. Please help! Thanks!

    Please note that I used the same files mentioned by you - simplified version. As per my knowledge log file should be generated in the /default directory as you did not mention about any file path in the esb.log4j2.xml file. Please feel free to correct me wherever my understanding is wrong. Thanks in advance!


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 34.  RE: Use log4j2 in webmethods

    Posted Sat April 17, 2021 01:20 AM

    (post withdrawn by author, will be automatically deleted in 24 hours unless flagged)


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 35.  RE: Use log4j2 in webmethods

    Posted Wed September 22, 2021 08:32 AM

    Is this topic still open? I had a similar challenge for WxConfig and was able to solve it without changes to Tanuki Wrapper. Anybody interested?


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 36.  RE: Use log4j2 in webmethods

    Posted Wed September 22, 2021 10:44 AM

    Christoph, though this is marked as a solved topic, it’ll be valuable if you can compile the resolution for others to have an alternate solution.

    KM


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 37.  RE: Use log4j2 in webmethods

    Posted Thu September 23, 2021 01:41 AM

    Hi Chris, I am interested in the solution found by you, albeit, it got resolved for me by some other method but still would be happy to know any potential alternatives. :slight_smile:


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 38.  RE: Use log4j2 in webmethods



  • 39.  RE: Use log4j2 in webmethods

    Posted Fri September 24, 2021 08:47 AM

    Christoph, Have you tried with the latest 2.14 jars for log4j2? The Git page does not mention the version of jog4j2 jars used. There seems to be a change in Log4J2 implementation where the logger has to be instantiated using LogManager class rather than LogContext. From what I am seeing there seems to be an internal SAG log4j2 config that is overriding the custom log4j2 properties resulting in the log entries being written to platform.log.

    As one of the posters mentioned above it seems using package class loader might have resolved the issue.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 40.  RE: Use log4j2 in webmethods

    Posted Mon September 27, 2021 03:16 AM

    The package simply uses the Log4j v2 that comes with IS. It was developed on IS 10.5 works nicely there.

    As to the other points you mentioned, I am not sure what you are aiming for. Is there a problem or are those general observations?

    Thanks.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 41.  RE: Use log4j2 in webmethods

    Posted Mon September 27, 2021 08:57 AM

    Just wanted clarity on what version of log4j2 jars you have used. If these are the ones that came with the SAG install then it will work but when using the ones(2.14) from Apache it still does not work. An observation.


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 42.  RE: Use log4j2 in webmethods

    Posted Mon September 27, 2021 09:24 AM

    Can you describe what you did and what does not work as expected? I did a quick test with 2.14.1 from the Apache site and it works for me.

    BTW: The version used by my IS 10.5 installation is 2.13.1, so not “miles apart” from the latest official release.

    Thanks!


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 43.  RE: Use log4j2 in webmethods

    Posted Thu November 11, 2021 12:06 PM

    Hi Chris,
    did you make update in the custom_wrapper.conf? If so could you please attache the same?


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 44.  RE: Use log4j2 in webmethods

    Posted Fri November 12, 2021 01:02 AM

    No changes were done to custom_wrapper.conf


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 45.  RE: Use log4j2 in webmethods

    Posted Fri December 03, 2021 05:19 PM

    Hi,

    I wanted to share something we found while trying to follow the various instructions in this topic. Everything worked well under 10.5, but on 10.7, the logging would work on our external gateway registration servers, but not on the internal servers. On the internal servers, when starting Integration Server, logging to our own file, and to sag-osgi.log and platform.log would suddenly stop halfway through the boot sequence, and from then on, everything would only go to the wrapper.log file. Even ehcache.log would not write anything.

    Last few entries in sag-osgi.log:

    2021-12-03 16:01:17,311 INFO  [com.w.p.PortalException                                     ] - No registered exception delegate
    2021-12-03 16:01:17,330 INFO  [tas.TaskCompletionHandlerIS                                 ] - Using system/lwq/dbhome directory for completion queue storage
    2021-12-03 16:01:17,352 INFO  [tas.TaskCompletionHandlerIS                                 ] - Initialized TaskCompletion Queue
    

    Last entry in ehcache.log:

    03.12.21 16:01:08.487 [INFO] | My webMethods Server 10.7.0.0001-0063
    

    After opening a ticket with Software AG, here is what we were told:

    I have analyzed the information that you provided.

    I found that the main difference between your IS v10.5 master, IS v10.7 proxy, and IS v10.7 master instances is that the effective value of the “log4j.configurationFile” System Property is different. For both the IS v10.5 master and IS v10.7 proxy instances (i.e. the “working” instances), the effective value of this property is pointing to the “log4j2.properties” file. However, with the IS v10.7 master instance (i.e. the “non-working” instance), the effective value of this property is "jar\:file\:/opt2/webmethods/IIS/common/lib/wm-caf-common.jar!/logging_config.xml"

    I can see that this property is configured in the IS v10.7 master instance’s custom_wrapper.conf file with the following line:

    ===
    wrapper.java.additional.204=-Dlog4j.configurationFile=“/opt2/webMethods/IIS/profiles/IS_IIS/configuration/logging/log4j2.properties,.tc.custom.log4j2.properties”
    ===

    Unfortunately, this property is being overridden during initialization of the Central User Management utility. This is an intentional change that was made to the CipherUtil class used by MWS/Central User Management. That change happened between v10.5 and v10.7.

    Software AG’s suggestion to write the custom code is difficult to do in version 2 of log4j logging facility. In version 1, you could point to your own configuration file using a call to DOMConfigurator.configure. However, in version 2, there is no public function performing this task. The Log4j2 documentation mentions a service, but warns that this is not a publicly exposed service, and that if you use it, your code could break with any updates to log4j2 library.

    We also thought of using pub.flow.debugLog in package WmPublic, but that would have logged to the server.log file, which was not ideal.

    What we decided to do, until we have a better solution, is to update the file logging_config.xml inside the JAR file /opt2/webMethods/IIS/common/lib/wm-caf-common.jar. We used unzip to extract all the files, made our change in logging_config.xml, and used zip -r to create an updated jar file. We kept a copy of the original jar, as reference, and overwrote the one in IIS/common/lib.

    We then restarted Integration server. We now have our logging working, and at the same time, the usual logging in wrapper.log continues as it should so it will not affect Web Methods normal operation.

    Until there is a better solution, this is what we will be using.

    Maybe in a future version of Web Methods Integration Server and MWS, Software AG will make a change to make the use of log4j2 easier.

    Original logging_config.xml file inside wm-caf-common.jar :

    <Configuration status="WARN">
    <Appenders>
    <Console name="Console" target="SYSTEM_OUT">
    <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
    </Console>
    </Appenders>
    <Loggers>
    <Root level="info">
    <AppenderRef ref="Console"/>
    </Root>
    </Loggers>
    </Configuration>
    

    After our changes :

    <Configuration status="WARN">
    <Appenders>
    <Console name="Console" target="SYSTEM_OUT">
    <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
    </Console>
    <!-- MyFile is for writing to file myfile.log with a log rotation of 1 day, gziping the file -->
    <RollingFile name="MyFile" fileName="mylogdir/myfile.log" filePattern="mylogdir/myfile.log.%d{yyyy-MM-dd}.gz">
    <PatternLayout>
    <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %p %c - %msg%n</pattern>
    </PatternLayout>
    <Policies>
    <TimeBasedTriggeringPolicy interval="1" modulate="true" />
    </Policies>
    </RollingFile>
    </Appenders>
    <Loggers>
    <!-- log anything from class Log4j2Tests into the myfile.log file -->
    <Logger name="Log4j2Tests" level="debug" additivity="false">
    <AppenderRef ref="MyFile" />
    </Logger>
    
    <Root level="info">
    <AppenderRef ref="Console"/>
    <!-- uncomment the following if you also want to log the console messages to myfile.log file -->
    <!--    <AppenderRef ref="MyFile"/>    -->
    </Root>
    </Loggers>
    </Configuration>
    

    Hopefully this can be useful to someone else using Integration Server 10.7

    Please note that we did not use our own version of log4j2 libraries, we simply used whatever version came with Integration Server 10.7.


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 46.  RE: Use log4j2 in webmethods

    Posted Sat December 04, 2021 07:40 AM

    This is the same issue that I faced when i tested with 10.7 couple of months ago when I posted my reply above. I suspected this was a product issue but it was not a mission critical issue for us to open a ticket with SAG so I just ignored it. I am glad you did and thanks for sharing the Root cause and the work around for the issue.


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 47.  RE: Use log4j2 in webmethods

    Posted Sat December 04, 2021 03:15 PM

    Hi @StA_A_phane_Desmarais,
    Thanks so much for sharing your experience with detailed workaround steps. I created an internal ticket for the respective team (MWS) and we hope to address this issue soon. If you like, you could create a ticket with support and request your ticket to be linked with this thread and that ticket (MWS-30139).

    Thanks again.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 48.  RE: Use log4j2 in webmethods

    Posted Tue December 07, 2021 10:51 AM

    Hello @StA_A_phane_Desmarais,
    The MWS team looked into this and shared that the issue you found is fixed in MWS_10.7_Fix2, which got released about 3 weeks ago. When reviewing the readme of this fix, please look for these defect references: MWS-29054, MWS-29016 and MWS-29532. When you get a chance, please try to apply this fix and see if the issue gets resolved without your workaround in place. If it is still an issue, please contact Software AG Global Support and mention that you like to reopen the defect # MWS-30139.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 49.  RE: Use log4j2 in webmethods

    Posted Tue December 07, 2021 05:54 PM

    Thank you Senthil,

    I was able to get my hands on the readme file for MWS_10.7_Fix2 and the description for MWS-29532 does fit my issue.

    I will talk to the person in charge of applying patches on these development hosts.


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 50.  RE: Use log4j2 in webmethods

    Posted Tue December 07, 2021 06:09 PM

    Very nice to hear Stéphane! Thanks for updating us.


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 51.  RE: Use log4j2 in webmethods

    Posted Wed January 05, 2022 02:38 PM

    Hi Senthil,

    If we use Integration Server and MWS 10.11 instead of 10.7, is this fix is already included in 10.11 ?


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 52.  RE: Use log4j2 in webmethods

    Posted Wed January 05, 2022 03:02 PM

    Hi Stéphane,

    I don´t think so.

    wM 10.11 was released in October 2021 and the log4j issue came up in Mid of December 2021.
    There were some fixes released in the last few days so you should check your UpdateManager for recent fixes.
    Check Empower for the Remediation Advisory for this issue additionally.

    Regards,
    Holger


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 53.  RE: Use log4j2 in webmethods

    Posted Wed January 05, 2022 03:21 PM

    Hi Holger,

    My question is not about the log4j2 vulnerability. It’s for my original question regarding the fact that our changes to log4j2.properties file were being ignored midway through starting Integration Server, and for which Senthil said to see fix in 10.7:

    MWS-29532 (MWS_10.7_Fix2)
    When initializing, the Common Directory Services package in Integration Server changes the value
    of the log4j.configurationFile system property and redirects the log output for ActiveTransfer.log
    to the wrapper.log
    (reference: https://empower.softwareag.com/sl24sec/fixsis_extern/FIXSIS2/ALL/MWS/107/MWS_10.7_Fix2_Readme.txt?prdfamily=webMethods


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 54.  RE: Use log4j2 in webmethods

    Posted Wed January 05, 2022 03:34 PM

    @StA_A_phane_Desmarais , changes are part of 10.11 GA release for MWS-29532.

    Regards,
    -Kalpesh


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 55.  RE: Use log4j2 in webmethods

    Posted Fri December 10, 2021 05:20 PM

    I decided to try Christoph Jahn’s solution, using calls to some non-public Log4j2 services, adapting for my own use, and it is working. So I have 3 solutions now

    1. Using calls to non-public Log4j2 library
    2. Adding my customer log4j configuration in file logging_config.xml inside the JAR file common/lib/wm-caf-common.jar
    3. applying the patches to MWS recommended by Senthil Kumar and add my .properties file in the custom_wrapper.conf in -Dlog4j.configurationFile

    Thanks to everyone who contributed to this trail. It was really helpful.


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 56.  RE: Use log4j2 in webmethods



  • 57.  RE: Use log4j2 in webmethods

    Posted Fri January 07, 2022 12:00 PM

    Side note: this entire thread reinforces that we made the right decision to avoid direct use of log4j like the plague. As with so many libraries/facilities that originally started off lean and useful, this one has gone bonkers and tries to do far too much, IMO (and we get mind-boggling vulnerability because of a freaking logging utility!?). Of course YMMV.

    For custom logging we created a couple of helper services. First is a wrapper service that uses the same class IS uses internally to write and daily rotate stats.log.

    // Wrapper service for com.wm.app.b2b.server.ServerAPI.getLogStream.
    // This is what IS uses internally to write and rotate stats.log.
    //
    // Opens a log file in the server's default logs directory. 
    // This should only be used to obtain handles to new log files for 
    // solution-specific logging purposes. By convention, the name should 
    // be something like "myapp.log".
    // 
    // The returned stream is intended to kept open for the life of the
    // JVM (don't open a whole bunch of these).
    // 
    // This service maintains a hash table of log streams that have
    // been opened keyed by the logfile parameter. If the log has 
    // been previously opened, the existing stream is returned and 
    // the "newLog" is set to "false". If the log is opened for the
    // first time a new stream is returned and the output parameter
    // "newLog" is set to "true".
    public static final void getLogStream(IData pipeline) throws ServiceException {
    IDataCursor idc = pipeline.getCursor();
    String logfile = IDataUtil.getString(idc, "logfile");
    
    boolean newLog = false;
    com.wm.app.b2b.server.LogOutputStream os = 
    (com.wm.app.b2b.server.LogOutputStream)openLogFiles.get(logfile);
    
    if(os == null)
    {
    os = com.wm.app.b2b.server.ServerAPI.getLogStream(logfile);
    openLogFiles.put(logfile, os);
    newLog = true;
    }
    
    IDataUtil.put(idc, "logStream", os);
    IDataUtil.put(idc, "newLog", ""+newLog);
    idc.destroy();
    }
    
    // --- <<IS-BEGIN-SHARED-SOURCE-AREA>> ---
    
    private static final java.util.Hashtable openLogFiles = new java.util.Hashtable();
    
    

    Next is a helper to write to the log stream. This can be adjusted to support different input types such as a byte array, but typically supporting string is sufficient.

    public static final void writeLogStream(IData pipeline) throws ServiceException {
    IDataCursor idc = pipeline.getCursor();
    com.wm.app.b2b.server.LogOutputStream os = 
    (com.wm.app.b2b.server.LogOutputStream)IDataUtil.get(idc, "logStream");
    String message = IDataUtil.getString(idc, "message");
    idc.destroy();
    
    os.write(message);
    }
    

    A FLOW service would call getLogStream to create/get a stream and then write to it using writeLogStream.

    For a given log, one can create another service that encapsulates the filename and the writing in a single call:

    writeMyLog
    ..Input: message (string)
    ..Output: (none)
    ..Tree:
    ....MyUtils:getLogStream
    ......logFile = "MyLog.log"
    ....MyUtils:writeLogStream
    ......logStream = (stream returned by getLogStream)
    ......message = (message passed by caller to this service)
    

    One can create multiple “writeMyLog” services in various packages as desired. This doesn’t have all the flexibility of log4j (logging levels and all that) but doesn’t have the complexity either. :slight_smile:

    Edit: Forgot to emphasize that IS will automatically rotate such logs daily, same as is done with the stats.log file.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 58.  RE: Use log4j2 in webmethods

    Posted Fri January 07, 2022 01:16 PM

    Rob,
    What mode do these log services use? Sync or Async? The only thing I like about log4j is its configurable properties at interface level and then async option. I agree with your comment on it trying to do too much.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 59.  RE: Use log4j2 in webmethods

    Posted Fri January 07, 2022 02:01 PM

    The services themselves do not control sync/async. A caller could do something to invoke them in an async way. The javadoc for the underlying class that is used does not indicate if it is sync/async. My bet is sync.

    Beware the desire to use async under the impression that it will be faster. There is a very high probability that the time taken to write a log sync does not matter at all for a given integration. Doing async logging by default may fall under the “don’t optimize prematurely” guideline. :slight_smile:

    One could add a simple mechanism to control what gets logged and what doesn’t in the write service, but we’ve found (so far) that the broad brush approach is sufficient. Just write to the log and have a scheduled task to remove old logs each week/month/whatever. Keeps things simple.


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 60.  RE: Use log4j2 in webmethods

    Posted Wed January 26, 2022 08:52 AM

    Hi,
    This is extension to my original question. now i could write to custom log file using webMethods 10.5 and log4j2 by following @Christoph_Jahn 's solution.
    Now, I have a dependent jar file to that package and that also need to write log to the same custom log file. As logger instance will be created only once i expect the logger statements inside the jar to write to same custom log file as webMethods code does. But, It’s not working. Kindly help me here if you have any idea.
    Thanks in Advance!
    Vignesh


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 61.  RE: Use log4j2 in webmethods

    Posted Mon April 25, 2022 07:33 AM

    Hi @Senthil

    I am going through the above thread since i am implementing the custom logging framework.
    I am using the SAG 10.3 version, and this is my esb.log4j2 file.

    <?xml version="1.0" encoding="UTF-8"?> packages/CustomLogging/resources/logs/rolling-file.log packages/CustomLogging/resources/logs/rolling-file-%d{yyyy-MM-dd}-%i.log %d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %m%n
    <Appenders>
    <RollingFile name="MyRollingFile" fileName="${FileName}" filePattern="${FileNamePattern}">
    <PatternLayout pattern="${LogPattern}"/>
    <Policies>
    <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
    </Policies>
    </RollingFile>
    </Appenders>
    <Loggers>
    <Logger name="COELogger" level="info" additivity="false">
    <AppenderRef ref="MyRollingFile"/>
    </Logger>
    </Loggers>
    

    Now in the custom_wrapper.config can i add the properties like this

    Existing one — wrapper.java.additional.204=-Dlog4j.configuration=file:///C:\SoftwareAG\IntegrationServer\instances\default\log4j.properties
    Append this new one in the file – “wrapper.java.additional.206=-Dlog4j.configurationFile=C:\SoftwareAG\IntegrationServer\instances\default\packages\Pepco_Common_ErrorHandling\config\esb.log4j2.xml”.

    should i add this as well “wrapper.java.additional.204.stripquotes=TRUE”

    Also esb.log4j2.xml file supports in 10.3 version since there we have log4j.properties is the existing one?
    Can someone please help me how to implement it?


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 62.  RE: Use log4j2 in webmethods

    Posted Mon April 25, 2022 08:33 AM

    Hi,
    This might be silly.

    Also one more question why we need to do with new log4j file(esb.log4j2.xml), the customized one when we already have the existing log4j2 file existing(default one)?

    Can someone help me to understand this.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 63.  RE: Use log4j2 in webmethods

    Posted Mon July 04, 2022 01:42 AM

    Hi,

    I have implemented the custom logging in 10.11 designer using the esb.log4j.xml file. The logs are getting generated in the provider and consumer side… But when the logs are getting generated the log entries are happening like this.

    Provider side:

    Consumer side:

    Please help me to understand why is this coming in the red highlighted box, how to avoid getting this?


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 64.  RE: Use log4j2 in webmethods

    Posted Thu July 07, 2022 01:10 AM

    Hello Maheswari,

    Its coming from the pattern layout. can you remove the [%t] in the log4j2 file and see. %t means the thread which is invoking the service.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 65.  RE: Use log4j2 in webmethods

    Posted Fri July 08, 2022 05:11 AM

    Hi Saran,

    I have also tried the same. it was working.

    Thanks.


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 66.  RE: Use log4j2 in webmethods

    Posted Fri July 08, 2022 05:24 AM

    HI Maheshwari,

    Thanks .im facing the issue where custom loggings were written to same file even though im calling from different packages.

    To elaborate the issue ,i have added two packages a/config/ log4j2.xml,b/config/ log4j2.xml in custom wrapper .conf and when i called from any one packages all the logs are going to b.log.

    Do you have any idea about this


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 67.  RE: Use log4j2 in webmethods

    Posted Fri July 08, 2022 06:28 AM

    Hi Saran,

    What is the file path location we have specified in the log4j2.xml file, the logs will be placed there.
    image

    Can you please provide different file path in these two log files and check the logs.
    Thanks.


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 68.  RE: Use log4j2 in webmethods

    Posted Fri July 08, 2022 07:00 AM

    Hello Maheswari/All

    Yeah i did that too .But its writing to same file. initially it created 2 files for each log4j2 config but its writing the logs to only one file.

    any idea.

    java code:

    	public static final void loggingcheck(IData pipeline) throws ServiceException {
    loggername="namespace.pkg1"(values dynamically passing from run time it should be namespace.pkg1/namespace.pkg2  )
    Logger	logger = LogManager.getLogger("loggername");
    logger.info("testing");
    System.out.println("Hello");
    
    }
    

    pkg1 log4j1 File

    <?xml version="1.0" encoding="UTF-8"?>
    <Configuration>
    <Appenders>
    <File name="A1" fileName="/app/opt/sag/webmethods/SITISA/IntegrationServer/instances/default/packageLogs/pkg1.log" append="true" MaxFileSize="5MB" MaxBackupIndex="10" >
    <PatternLayout pattern="%d %-5p [%t] - %m%n"/>
    </File>
    <Console name="Console" target="SYSTEM_OUT">
    <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
    </Console>
    </Appenders>
    <Loggers>
    <Logger name="namespace.pkg1" level="info">
    
    <AppenderRef ref="A1"/>
    <AppenderRef ref="Console"/>
    
    </Logger>
    </Loggers>
    </Configuration>
    

    Pkg2 log4j2 File:

    <?xml version="1.0" encoding="UTF-8"?>
    <Configuration>
    <Appenders>
    <File name="A1" fileName="/app/opt/sag/webmethods/SITISA/IntegrationServer/instances/default/packageLogs/pkg2.log" append="true" MaxFileSize="5MB" MaxBackupIndex="10" >
    <PatternLayout pattern="%d %-5p [%t] - %m%n"/>
    </File>
    <Console name="Console" target="SYSTEM_OUT">
    <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
    </Console>
    </Appenders>
    <Loggers>
    <Logger name="namespace.pkg2" level="info">
    
    <AppenderRef ref="A1"/>
    <AppenderRef ref="Console"/>
    
    </Logger>
    </Loggers>
    

    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 69.  RE: Use log4j2 in webmethods

    Posted Fri July 08, 2022 07:18 AM

    Hi,
    Can you try with this xml file?

    Change the file path in the log4j2.xml file. keep everything in the xml file and just invoke the logger property Name in the java code.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 70.  RE: Use log4j2 in webmethods

    Posted Fri July 08, 2022 07:27 AM


  • 71.  RE: Use log4j2 in webmethods

    Posted Fri July 08, 2022 09:50 AM

    Hi Maheshwari,

    Its not working for me,did you tried with two logger names(ie two packages.).if so could you please tell me what are the steps you did.


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 72.  RE: Use log4j2 in webmethods

    Posted Thu September 01, 2022 10:06 AM

    Hi @sarankumar.kannan,

    The issue you’re running into could be related to class loading (see Reverb) As described in the documentation, more specifically in the “Class Searching Order” page, the IS will search for classes (and other resources) in the server classpath first, then locally within the package, and then in all the required packages. Your custom package may be loading the incorrect Log4J configuration file due to this search order. You can easily test this theory by adding the following to your packages manifest.v3 file and reloading the package (or restarting the server):

    <value name="classloader">package</value>

    I had a very similar issue when moving a customer’s logging package (built on Log4J) from 10.3 to 10.11. In this package, the LoggerContext is initialized with:

    context = Configurator.initialize(CONFIG_NAME, null, CONFIG_FILE);

    … and although this worked fine in 10.3, in 10.11 the wrong Log4J configuration was being picked up. Adding the line above to the package’s manifest file caused the proper configuration to be picked up without code changes. There are code alternatives to this solution as well if changing the manifest file is undesired.

    Hope this helps,
    Percio


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 73.  RE: Use log4j2 in webmethods

    Posted Fri September 23, 2022 03:13 AM

    Hi everyone,

    Can you please help me to use to shared folder path in the log4j properties File? How to configure or change the file path to use the shared folder.

    Old Property file :

    <Properties>
    <Property name="FileName">D:/Logs/ESB_${hostName}.log</Property>
    <Property name="FileNamePattern">D:/Logs/ESB_${hostName}-%d{yyyy-MM-dd}-%i.log</Property>
    <Property name="LogPattern">%d{yyyy-MM-dd HH:mm:ss} %-5p %m%n</Property>
    </Properties>
    

    New PropertyFile using shared folder path:

    <Properties>
    <Property name="FileName">SharedFileHostName/SharedFileuserName/SharedFilePassword/D:/Dev-Logs/ESB_${hostName}.log</Property>
    <Property name="FileNamePattern">SharedFileHostName/SharedFileUserName/SharedFilePassword/D:/Dev-Logs/ESB_${hostName}-%d{yyyy-MM-dd}-%i.log</Property>
    <Property name="LogPattern">%d{yyyy-MM-dd HH:mm:ss} %-5p %m%n</Property>
    </Properties>
    

    Old PropertyFile is working fine with the filename, but when i change the filename to shared folder location, it is not working? Someone help me on this.


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB