Using Log4j Logging for Coherence Logs

Using Log4j Logging for Coherence Logs

book

Article ID: KB0091080

calendar_today

Updated On:

Products Versions
TIBCO BusinessEvents Enterprise Edition -
Not Applicable -

Description

Resolution:
Description:
===========
Using Log4j Logging for Coherence Logs

Environment:
===========
TIBCO BusinessEvents (BE) 3.0.x, 4.0.x
Oracle Coherence

Resolution:
========
When using Oracle(Coherence) as cache provider in BE, you can configure Coherence to use log4j logging.
To use log4j logging for Coherence logs:

1) Point tangosol.coherence.log to log4j

2) Create a log4j.properties file(examples as below). For the file appender, make sure the specified directory can be accessed and has write permissions.

3) Make sure both the log4j.properties file and log4j.jar file are found on the classpath at runtime. For example, save log4j.properties file under &ltBE_HOME>/hotfix/lib/ext


Examples:
========
BE 3.0.x:

1) TRA file
       1-1) Add  below property to TRA and point it to log4j:
                       java.property.tangosol.coherence.log=log4j
       1-2) Increase coherence log level to enable debug
                      java.property.tangosol.coherence.log.level=9
                      java.property.tangosol.coherence.log.limit=0

2) Create a new file called log4j.properties, and save it to &ltBE_HOME>/hotfix/lib/ext

log4j.rootLogger=debug, COHERENCE
log4j.appender.COHERENCE=org.apache.log4j.FileAppender
log4j.appender.COHERENCE.layout=org.apache.log4j.PatternLayout
log4j.appender.COHERENCE.layout.ConversionPattern=%d [%-5p]%x %c{1} - %m%n%n

# change the location and the filename on your system
log4j.appender.COHERENCE.File=c:/tmp/coherenceCache2.log
log4j.appender.COHERENCE.Append=true

=========
BE 4.0.x:

1) CDD file

1-1) Point tangosol.coherence.log to log4j(for example, on PU level)
tangosol.coherence.log=log4j

1-2) Increase coherence log level to enable debug
tangosol.coherence.log.level=9
tangosol.coherence.log.limit=0

2) Create a new file called log4j.properties, and save it to &ltBE_HOME>/hotfix/lib/ext

log4j.logger.Coherence=INFO,stdout,coherence_log4j
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%m%n

log4j.appender.coherence_log4j=org.apache.log4j.RollingFileAppender
log4j.appender.coherence_log4j.File=C:/temp/coherence_log4j.log
log4j.appender.coherence_log4j.threshold=DEBUG
log4j.appender.coherence_log4j.MaxFileSize=1GB
log4j.appender.coherence_log4j.layout=org.apache.log4j.PatternLayout
log4j.appender.coherence_log4j.layout.ConversionPattern=%m%n
log4j.appender.coherence_log4j.Append=true

Notes:
- You can configure log4j logger with different appender. In the above examples, 3.0.x example is configured with org.apache.log4j.FileAppender and 4.0.x example uses the org.apache.log4j.RollingFileAppender
- In the above examples, Coherence is used as the logger object name and is the default name used by Coherence. A different name can be used by specifying the name of the tangosol.coherence.log.logger system property. Add this property to TRA/CDD file and configure the logger object name you want to use

Reference:
=========
http://docs.oracle.com/cd/E24290_01/coh.371/e22837/gs_debug.htm#BABHEBJI

Issue/Introduction

Using Log4j Logging for Coherence Logs