How to write TIBCO BusinessEvents log to multiple log files

How to write TIBCO BusinessEvents log to multiple log files

book

Article ID: KB0082278

calendar_today

Updated On:

Products Versions
TIBCO BusinessEvents Enterprise Edition -

Description

Sample Use-case:
Redirect all INFO and above level entries to one log file, all WARNINGs and above to one log file and all ERRORs and above to one log file for better tracking and monitoring purpose.  This is needed so that customers can keep an eye on critical errors and preserve the logs and timestamps especially when logs get rolled over very frequently.
>>>>>>>>>>>>>>>>>>>>>>>
2018 Mar 23 10:32:29.955 GMT-07:00 INFO [http.server.impl] - Channel server for HTTP Channel[Port:8109] starting
2018 Mar 23 10:32:29.967 GMT-07:00 INFO [http.server.impl] - Channel server for HTTP Channel[Port:8109] successfully started
2018 Mar 23 10:33:10.950 GMT-07:00 WARN [cep.driver.jms] - JMS FT event: [FT-SWITCH: Disconnected from tcp://localhost:7222, will attempt to reconnect] [Disconnected from tcp://localhost:7222, will attempt to reconnect]
2018 Mar 23 10:33:10.953 GMT-07:00 WARN [cep.driver.jms] - JMS FT event: [FT-SWITCH: Disconnected from tcp://localhost:7222, will attempt to reconnect] [Disconnected from tcp://localhost:7222, will attempt to reconnect]
2018 Mar 23 10:33:11.284 GMT-07:00 INFO [cep.driver.jms] - JMS FT event: [FT-SWITCH: Reconnecting to tcp://localhost:7222, attempt 1 out of 2] [Reconnecting to tcp://localhost:7222, attempt 1 out of 2]
2018 Mar 23 10:33:11.288 GMT-07:00 INFO [cep.driver.jms] - JMS FT event: [FT-SWITCH: Reconnecting to tcp://localhost:7222, attempt 1 out of 2] [Reconnecting to tcp://localhost:7222, attempt 1 out of 2]
2018 Mar 23 10:33:13.307 GMT-07:00 INFO [cep.driver.jms] - JMS FT event: [FT-SWITCH: Reconnecting to tcp://localhost:7222, attempt 1 out of 2] [Reconnecting to tcp://localhost:7222, attempt 1 out of 2]
2018 Mar 23 10:33:15.317 GMT-07:00 INFO [cep.driver.jms] - JMS FT event: [FT-SWITCH: Reconnecting to tcp://localhost:7222, attempt 1 out of 2] [Reconnecting to tcp://localhost:7222, attempt 1 out of 2]
2018 Mar 23 10:33:17.623 GMT-07:00 INFO [cep.driver.jms] - JMS FT event: [FT-SWITCH: Reconnecting to tcp://localhost:7222, attempt 2 out of 2] [Reconnecting to tcp://localhost:7222, attempt 2 out of 2]
2018 Mar 23 10:33:19.670 GMT-07:00 INFO [cep.driver.jms] - JMS FT event: [FT-SWITCH: Reconnecting to tcp://localhost:7222, attempt 2 out of 2] [Reconnecting to tcp://localhost:7222, attempt 2 out of 2]
2018 Mar 23 10:33:21.358 GMT-07:00 INFO [cep.driver.jms] - JMS FT event: [FT-SWITCH: Reconnecting to tcp://localhost:7222, attempt 2 out of 2] [Reconnecting to tcp://localhost:7222, attempt 2 out of 2]
2018 Mar 23 10:33:23.368 GMT-07:00 INFO [cep.driver.jms] - JMS FT event: [FT-SWITCH: Reconnecting to tcp://localhost:7222, attempt 2 out of 2] [Reconnecting to tcp://localhost:7222, attempt 2 out of 2]
2018 Mar 23 10:33:27.395 GMT-07:00 ERROR [cep.driver.jms] - JMS Exception [code]:null [message]:Connection has been terminated
2018 Mar 23 10:33:27.395 GMT-07:00 ERROR [cep.driver.jms] - JMS Exception [code]:null [message]:Connection has been terminated
2018 Mar 23 10:33:27.396 GMT-07:00 ERROR [cep.driver.jms] - JMS Linked exception [message]: Connection reset
2018 Mar 23 10:33:27.396 GMT-07:00 ERROR [cep.driver.jms] - JMS Linked exception [message]: Connection reset
2018 Mar 23 10:33:27.398 GMT-07:00 ERROR [cep.driver.jms] - Exception while receiving a JMS message => stopping the receiver, jmsSessionPerMessage:false, ack:true, ErrorCode:null, in: inference-class
javax.jms.JMSException: Connection has been terminated
    at com.tibco.tibjms.TibjmsxSessionImp._getSyncMessage(TibjmsxSessionImp.java:2301)
    at com.tibco.tibjms.TibjmsxSessionImp._receive(TibjmsxSessionImp.java:2122)
    at com.tibco.tibjms.TibjmsMessageConsumer._receive(TibjmsMessageConsumer.java:276)
    at com.tibco.tibjms.TibjmsMessageConsumer.receive(TibjmsMessageConsumer.java:481)
    at com.tibco.cep.driver.jms.JmsReceiver.if(SourceFile:236)
    at com.tibco.cep.driver.jms.JmsReceiver.call(SourceFile:133)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
2018 Mar 23 10:33:27.399 GMT-07:00 INFO [cep.driver.jms] - Destination [/JMSChannel/jmsDest1] listener STOPPED for RuleSession [inference-class] {2}
2018 Mar 23 10:33:27.399 GMT-07:00 ERROR [cep.driver.jms] - Failed to recover JMS session in: inference-class
javax.jms.IllegalStateException: Session is closed
    at com.tibco.tibjms.TibjmsxSessionImp._recover(TibjmsxSessionImp.java:2743)
    at com.tibco.tibjms.TibjmsxSessionImp.recover(TibjmsxSessionImp.java:5246)
    at com.tibco.cep.driver.jms.JmsReceiver.if(SourceFile:258)
    at com.tibco.cep.driver.jms.JmsReceiver.call(SourceFile:133)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
<<<<<<<<<<<<<<<<<<<<<<<

Issue/Introduction

How to write TIBCO BusinessEvents log to multiple log files

Environment

All Supported Envrionments

Resolution

This can be achieved by defining multiple log files using single log4j configuration, and configure BE logging with the customized log4j configuration.
1. Disable the default logging mode and use the log4j mode for logging
See the below link for how to overriding the Default Logging Mode:
https://docs.tibco.com/pub/businessevents-standard/5.4.1/doc/html/GUID-B5B063CB-F2AF-4A31-B4F3-602C4C476BA1.html
2. Create one's own log4j configuration with multiple Log files
<appender name="normal" class="org.apache.log4j.RollingFileAppender"> 
	<param name="file" value="D:/WorkingSpaces/BE550/TEMP_64/normal.log"/>
	<param name="MaxFileSize" value="100MB"/>
	<param name="MaxBackupIndex" value="10"/>
	<layout class="org.apache.log4j.PatternLayout"> 
	    <param name="ConversionPattern" value="%d{yyyy MMM dd HH:mm:ss.SSS 'GMT'XXX} %p [%c{3}] - %m%n"/> 
	</layout> 
</appender> 

<appender name="Error" class="org.apache.log4j.RollingFileAppender"> 
	<param name="file" value="D:/WorkingSpaces/BE550/TEMP_64/Error.log"/>
	<param name="MaxFileSize" value="100MB"/>
	<param name="MaxBackupIndex" value="10"/>
	<param name="threshold" value="error"/>
	<layout class="org.apache.log4j.PatternLayout"> 
		  <param name="ConversionPattern" value="%d{yyyy MMM dd HH:mm:ss.SSS 'GMT'XXX} %p [%c{3}] - %m%n"/> 
	</layout> 
</appender>
3. Refer to appender in root logger
<root> 
	<priority value ="info" /> 
	<appender-ref ref="normal" /> 
	<appender-ref ref="Error"/>
</root>
4. Add the following property in the be-engine.tra file to use this custom log4j configuration
java.property.log4j.configuration=[custom_log4j_path]
    Note: if the custom log4j file is not in the classpath but located elsewhere on your device, use the following in be-engine.tra file:
java.property.log4j.configuration=file:[custom_log4j_file_path]
See attached log4j.xml for your reference. With this custom log4j, we defined the following appenders:
- console   will direct logs to console
- normal  the normal BE log(similar to log files generated with default logging mode) which will be written to normal.log
- Warn     logs at Warn level and above will be written to Warn.log
- Error     logs at Error level and above will be written to Error.log
Also see normal.log, Warn.log, Error.log which were generated by one BE engine from the attached sample_logs.zip for your reference.
 

Additional Information

see the official log4j wiki page for more information on log4j configurations at 
http://wiki.apache.org/logging-log4j/Log4jXmlFormat

Attachments

How to write TIBCO BusinessEvents log to multiple log files get_app
How to write TIBCO BusinessEvents log to multiple log files get_app