Version: 17.07
UltraESB-X instances are by default configured with console log appender and file log appender that write the log entries to the console and to the file system respectively. In addition to those, the database log appender can be configured to persist log entries to a database, in order to be used by other utility applications such as IMonitor-X.
First of all, define the database log appender as follows inside the Appenders
tag of the conf/log4j2.xml
file
of the UltraESB-X instance.
<JDBC name="DATABASE_APPENDER"
tableName="LOG_ENTRY"> (1)
<UltraCPDataSource
driverClass="com.mysql.jdbc.Driver" (2)
url="jdbc:mysql://localhost:3306/IMX_DB?useSSL=false" (3)
initialSize="5" (4)
minSize="2" (5)
maxTotal="20" (6)
validationQuery="SELECT 1 FROM DUAL" (7)
waitTimeToInitialize="-1" (8)
poolName="log" (9)
connectionIdleMillis="60000" (10)
connectionWaitMillis="6000" (11)
refreshIntervalMillis="20000"> (12)
<ConnectionProperty key="user" value="imuser"/> (13)
<ConnectionProperty key="password" value="password"/> (14)
</UltraCPDataSource>
<Column name="NODE_NAME" pattern="node1" /> (15)
<Column name="CLUSTER_NAME" pattern="space1" /> (16)
<Column name="OCCURRENCE_TIME" isEventTimestamp="true" />
<Column name="IP_ADDRESS" pattern="%X{ip}" />
<Column name="HOSTNAME" pattern="%X{host}" />
<Column name="THREAD_NAME" pattern="%t" />
<Column name="LOG_CODE" pattern="%X{xc}" />
<Column name="LOG_LEVEL" pattern="%level" />
<Column name="CLASS_NAME" pattern="%c{1}" />
<Column name="LOG_MESSAGE" pattern="%m" />
<Column name="ERROR_DETAILS" isClob="true" pattern="%ex{full}" />
<Column name="PROJECT_NAME" pattern="%X{xsn}" />
<Column name="PROJECT_VERSION" pattern="%X{xsv}" />
</JDBC>
1 | Database table to which the logs should be persisted |
2 | Class name of the database driver. Use com.mysql.cj.jdbc.Driver for MySQL databases or oracle.jdbc.OracleDriver
for Oracle databases. |
3 | The connection URL for the database
|
4 | Initial number of database connections to be pooled |
5 | Minimum number of database connections to be pooled |
6 | Maximum number of database connections to be pooled |
7 | Database connection validation query |
8 | Maximum waiting time (in milliseconds) until the connection pool initialization (set as -1 to wait indefinitely) |
9 | Name for the connection pool |
10 | Maximum amount of time (in milliseconds) a connection can remain idle before it’s validated |
11 | Maximum amount of time (in milliseconds) a thread should wait to obtain a connection |
12 | Maximum amount of time (in milliseconds) the pool can have connections below the specified minimum |
13 | Username to be used for database connectivity |
14 | Password to be used for database connectivity |
15 | Node name of the UltraESB-X instance |
16 | Cluster space name of the UltraESB-X instance |
link:https://releases.xrepo.adroitlogic.com/maven2/org/adroitlogic/x/libraries/x-library-ultracp/17 .07/x-library-ultracp-17.07.jar[Adroitlogic UltraCP library]
Then assign this appender to any logger as you required.
Download the following jar files and place them in the lib/custom
directory of the UltraESB-X instance.
Database driver based on your database
MySQL JDBC driver
Oracle JDBC driver
Restart the UltraESB-X instance.