question

Upvote
Accepted
401 18 20 34

How to configure EMA Java to use log4j as the underlying logging backend?​

In the EMA Java Developer Guide, it mentions that EMA Java can have underlying logging backend to be Java standard logger (java.util.logging), log4j, or other loggers implementing SLF4J logging interface. I want to use log4j logging framework with EMA Java, how to configure EMA Java to use log4j as the underlying logging backend?

elektronrefinitiv-realtimeelektron-sdkrrtema-apielektron-message-apijava
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Upvotes
Accepted
1.2k 23 29 44

EMA/Java uses SLF4J, there are simple drop in jars from each logging API that act as a binding to automatically connect to log4j2 or otherwise.

For log4j2, simply add the SLF4J API and binding to the class path:

log4j-api-2.0.jar:log4j-core-2.0.jar:log4j-slf4j-impl-2.0.jar:slf4j-api-1.7.12.jar

Capture the EMA output with the following in log4j2.xml:

<Logger name="com.thomsonreuters.ema.access" level="trace" additivity="false">
  <AppenderRef ref="Console"/>
</Logger>

For log4j1, use the matching jars per the SLF4J manual:

slf4j-log4j12-1.7.21.jar:slf4j-api-1.7.21.jar

For J.U.L., documented on the same page above:

slf4j-jdk14-1.7.21.jar:slf4j-api-1.7.21.jar

For Logback, a popular alternative to log4j1:

logback-classic-1.0.13.jar:logback-core-1.0.13.jar:slf4j-api-1.7.21.jar
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.