This article explain how to link your java application with Apsolab-Server. Apsolab-IT and Apsolab-BI comes with one appender for Apache Log4J framework: XLogTagAppender. This appender has no limitation and no dependency. It can be added to any java application using Apache Log4J framework. If you already use some xml configuration file to setup your logging solution, you are on business. No code modification required. Just add our appender in your xml configuration file and your logs will be forwarded to Apsolab-Server! The jar file has been successfully tested under Linux and Windows (32/64 bits). It should run under any platform and if you have any problem, the source code is located under /opt/apsolab/latest/xlog4j. You can look in the source directories for example on how to use our appender.

Note: Within Apsolab, a ‘logger’ is a source (producer) of logs. So, a Log4J ‘appender’ is a ‘logger’ from Apsolab point of view. Within Log4J framework, a ‘logger’ has an other meaning. In other words, Log4J ‘logger’ is a log source for ‘appender’ and Log4J ‘appender’ is a ‘logger’ from Apsolab point of view.

XLogTagAppender Integration

To forward Log4J logs to Apsolab-Server using XLogTagAppender, you should follow the following steps:

  • Add xlog4j-<version>.jar file to your classpath (replace <version> with current product version)
  • Modify your Log4J xml configuration file to include (and attach) XLogTagAppender
  • Set the ‘Host’ param to Apsolab-Server host name or IP address
  • Don’t forget to use different logger name for each logger (Apsolab-Server require a unique logger name for each logger)

You can find the jar file in /opt/apsolab/latest/xlog4j/.

Appender parameters description:

Param Description
Host Apsolab-Server host name or IP address.
Port Apsolab-Server TAG service TCP port number.
ConnectionTimeout TCP connection timeout in ms.
ConnectRetryInterval TCP connection retry interval in ms.
MaxBufferSize Appender will buffer logs when disconnected from Apsolab-Server. This is the maximum buffer size in log count (number of logs). When MaxBufferSize limit is reached, older logs will be dropped.
ProductName Product name displayed in Apsolab-Server logs.
ProductVersion Product version displayed in Apsolab-Server logs.
ComponentName Component name displayed in Apsolab-Server logs.
ApplicationName Application name displayed in Apsolab-Server logs.
Category Log category. Default: Application.
LoggerName Logger name displayed in Apsolab-Server logs. Apsolab-Server require a unique logger name for each logger.
Threshold Appender (logger) startup threshold. This threshold will be overwrited by Apsolab-Server after connection. All loggers (appenders) threshold are controlled by Apsolab-Server and can be changed from Apsolab-Console (window: Logger).

Log4J xml configuration file example:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
    <appender name="XLOG4J" class="com.apsolab.xlog4j.XLogTagAppender">
        <param name="Host" value="localhost" />
        <param name="Port" value="33201" />
        <param name="ConnectionTimeout" value="1000" />
        <param name="ConnectRetryInterval" value="1000" />
        <param name="MaxBufferSize" value="5000" />
        <param name="ProductName" value="Apsolab-IT" />
        <param name="ProductVersion" value="0.4.0" />
        <param name="ComponentName" value="XLOG4J" />
        <param name="ApplicationName" value="SomeJavaApp" />
        <param name="LoggerName" value="xlog4jappender" />
        <param name="Threshold" value="trace" />
        <param name="Category" value="Application" />
    </appender>
<root>
    <level value="warning" />
    <appender-ref ref="XLOG4J" />
</root>
</log4j:configuration>