IBM Support

How to log different TDI Server Instances to the same log file.

Question & Answer


Question

Customers often want to run multiple TDI Server instances and have the logs appended to the same log file. The Apache Log4j website recommends a SocketAppender / SocketServer approach be used in this situation.

Cause

How do I get multiple processes to log to the same file?
You may have each process log to a SocketAppender. The receiving SocketServer (or SimpleSocketServer) can receive all the events and send them to a single log file.

Reference URL: http://logging.apache.org/log4j/1.2/faq.html#3.3

Answer


Instructions for configuring a TDI Server to communicate with a log4j SocketServer.

In this set of instructions, it is assumed a Solution directory has been defined. Otherwise, substitute the TDI install directory, if a Solution directory has not been defined.

The environment used for example is TDIv7.1.1 and the log4j-1.2.16.jar file. If you are configuring for a newer version of TDI, you will need to confirm the jar file version included in the <TDI_Install>\jars\3rdParty\others directory.

  1. SocketServer - A log4j SocketServer must be defined/setup on the network.
    *In this example, the SocketServer will be on the same machine as the TDI server and defined in the <TDI_SOLDIR>\etc\SocketServer_Config directory.
    1. Create a separate directory to run the SocketServer. (<TDI_SOLDIR>\etc\SocketServer_Config )
    2. Place a copy of the <SolutionDirectory>/etc/log4j.properties in this new directory.
    3. Rename it, for example server_log4j.properties
    4. Make the following modification to the Default Logger in the server_log4j.properties

      # This is the default SocketServer Logger, you will see that it logs to ibmdi_ServerSocket.log
      log4j.appender.Default=org.apache.log4j.FileAppender
      log4j.appender.Default.file=logs/ibmdi_ServerSocket.log
      log4j.appender.Default.layout=org.apache.log4j.PatternLayout
      log4j.appender.Default.layout.ConversionPattern=%d{ISO8601} %-5p [%c] - %m%n
      log4j.appender.Default.append=append
      ** If a different appender other then "FileAppender" is desired, please review Technote (1260820) for the parameters for a "Daily" or "Rolling" appender configuration.
2. Create a script to run the SocketServer:

      The syntax of the command comes from the following page -- SocketServer (Apache Log4j 1.2.15 API) - http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/net/SocketServer.html


      An EXAMPLE of the java command:

      <TDI_INSTALL_DIR>\jvm\jre\bin\java" -cp "<TDI_INSTALL_DIR>\jars\3rdparty\others\log4j-1.2.16.jar" org.apache.log4j.net.SocketServer 4560 <SocketServer_Dir>\server_log4j.properties <SocketServer_Dir>

      Key elements:
      • The name and location of the log4j-<version>.jar file
      • The directory and location of the socket servers property file (from step 1 above).
      • The port number (used in the TDI Server's log4j.properties file - step 3 below)


    3. TDI Server - The log4j.properties associated with the TDI Server must be modify to use the SocketAppender.

      1. - Locate the <Solution Directory>/etc/log4j.properties file.
      2. - Comment out this section in the log4j.properties file

        # This is the default logger, you will see that it logs to ibmdi.log
        #log4j.appender.Default=org.apache.log4j.FileAppender
        #log4j.appender.Default.file=logs/socket_ibmdi.log
        #log4j.appender.Default.layout=org.apache.log4j.PatternLayout
        #log4j.appender.Default.layout.ConversionPattern=%d{ISO8601} %-5p [%c] - %m%n
        #log4j.appender.Default.append=false
      3. - Add this section to the file

        # SocketAppender sending its output to the server running on the remote host, port 4560.
        log4j.appender.Default=org.apache.log4j.net.SocketAppender
        log4j.appender.Default.Port=<port number defined at SocketServer start>
        log4j.appender.Default.RemoteHost=<IP address of SocketServer>
          where
          • log4j.appender.Default.Port is defined and specified in the socketServer.bat file
          • log4j.appender.Default.RemoteHost is the IP of the address where the socketServer script has been started.


    The script to start the Socket server should be running prior to starting a TDI server. Otherwise, the following error may be seen:


    log4j:ERROR Could not connect to remote log4j server at [127.0.0.1]. We will try again later.

    [{"Product":{"code":"SSCQGF","label":"Tivoli Directory Integrator"},"Business Unit":{"code":"BU008","label":"Security"},"Component":"General","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"7.1.1","Edition":"","Line of Business":{"code":"LOB24","label":"Security Software"}}]

    Document Information

    Modified date:
    16 June 2018

    UID

    swg21393632