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.

 View Only
  • 1.  Log4j with xinclude

    Posted Thu December 01, 2016 12:08 PM

    Hi All,

    I am trying to implement logging framework with log4j.xml. Below is a sample of my file. But it is not working as expected. Can anyone tell me how we can do xi:include in log4j2??

    <log4j:configuration xmlns:log4j=“http://jakarta.apache.com” xmlns:xi=“XInclude” >

    <xi:include href=“/home/jack/logging/appenders.xml”>
    <xi:include href=“/home/jack/logging/loggers.xml”>

    </log4j:configuration>


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


  • 2.  RE: Log4j with xinclude

    Posted Thu December 01, 2016 04:14 PM

    Could you explain the reason for using Log4j as logging framework and not wM product suite using OOTB services and custom implementation?

    XInclude
    XML configuration files can include other files with XInclude. Here is an example log4j2.xml file that includes two other files:

    <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
    <configuration xmlns:xi="http://www.w3.org/2001/XInclude"
    status="warn" name="XIncludeDemo">
    <properties>
    <property name="filename">xinclude-demo.log</property>
    </properties>
    <ThresholdFilter level="debug"/>
    <xi:include href="log4j-xinclude-appenders.xml" />
    <xi:include href="log4j-xinclude-loggers.xml" />
    </configuration>
    log4j-xinclude-appenders.xml:
    
    <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
    <appenders>
    <Console name="STDOUT">
    <PatternLayout pattern="%m%n" />
    </Console>
    <File name="File" fileName="${filename}" bufferedIO="true" immediateFlush="true">
    <PatternLayout>
    <pattern>%d %p %C{1.} [%t] %m%n</pattern>
    </PatternLayout>
    </File>
    </appenders>
    log4j-xinclude-loggers.xml:
    
    <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
    <loggers>
    <logger name="org.apache.logging.log4j.test1" level="debug" additivity="false">
    <ThreadContextMapFilter>
    <KeyValuePair key="test" value="123" />
    </ThreadContextMapFilter>
    <AppenderRef ref="STDOUT" />
    </logger>
    
    <logger name="org.apache.logging.log4j.test2" level="debug" additivity="false">
    <AppenderRef ref="File" />
    </logger>
    
    <root level="error">
    <AppenderRef ref="STDOUT" />
    </root>
    </loggers>

    Source: Log4j – Configuring Log4j 2


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


  • 3.  RE: Log4j with xinclude

    Posted Mon September 11, 2017 12:37 AM

    This is a legacy application.

    Thanks Mahesh. It works. :slight_smile:

    Regards,
    Jacob


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