question

Upvotes
Accepted
19 3 7 8

Can we have handle to EMA logger to log the Channel UP related event to a specific file as part of log4j2 configuration?

Currently we see that these logging events are not logged to the designated file. Is there a way we can get handle in EMA for these events to log where we want to as part of our log4j configuration.?
Also can we override this functionality to rephrase this message ?

7:56:49.643 [INFO] main - OmmConsumerImpl - loggerMsg ClientName: ChannelCallbackClient Severity: Info Text: Received ChannelUp event on channel Channel_1

elektronrefinitiv-realtimeelektron-sdk
icon clock
10 |1500

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

Upvotes
Accepted
11.5k 16 7 10

Hello @gaurav.mahajan

Please be informed that the EMA Java API uses the Simple Logging Facade for Java (SLF4J) API as a facade for logging utility, so you can integrate the EMA Java application with Log4j. Even though the EMA Java API binds the logging mechanism with Java Logging API by default, developers can change the binding library and logging configuration files to bind the EMA Java application with Log4j or others framework that supported SLF4J without modify the application source code.

The EMA Java package contains two SLF4J library files

  • slf4j-api-1.7.12.jar
  • slf4j-jdk14-1.7.12.jar

The slf4j-api-1.7.12.jar file is the core SLF4J library file. The slf4j-jdk14-1.7.12.jar is a binding library file for Java Logging API. Developers can perform the following steps to integrate the EMA Java application log with Log4j framework.

  1. Replace this slf4j-jdk14-1.7.12.jar file with SLF4J-Log4j binding file
  2. Add Log4j required core library files to the Java classpath
  3. Configure configurations file to Java classpath or JVM option

The Log4j 2 framework requires the following libraries files in Java classpath to intergrate with EMA Java SLF4J framework:

  • log4j-api-<version>.jar
  • log4j-core-<version>.jar
  • log4j-slf4j-impl-<version>.jar
  • slf4j-api-<version>.jar

Then you can configure Log4j 2 configurations file to Java classpath or JVM option "-Dlog4j.configurationFile" at runtime to let the EMA Java application uses Log4j 2 configurations file.

icon clock
10 |1500

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

Upvotes
23k 22 9 14

Yes, from the developer guide:

"The EMA uses the SLF4J logging API, in which you can have the underlying logging backend be the Java standard logger utility package (java.util.logging), log4j, or other logger adapters which implement the SLF4J logging interface. "

The steps are:

1. As command line arguments we pass

"-Djava.util.logging.config.file=logging.properties"

2. Create a file "logging.properties" and put it into the same folder with the app

3. The sample contents of logging.properties to log into EMAExample.log file are:

    # Specify the handlers to create in the root logger
    # (all loggers are children of the root logger)
    
    # The following creates two handlers
    handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
    
    # Set the default logging level for the root logger
    .level = FINE
    
    # Set the default logging level for new ConsoleHandler instances
    java.util.logging.ConsoleHandler.level = FINE
    
    # Set the default logging level for new FileHandler instances
    java.util.logging.FileHandler.level = FINE
    java.util.logging.FileHandler.count = 7
    java.util.logging.FileHandler.pattern = ./EMAExample.log.%g
    java.util.logging.FileHandler.formatter= java.util.logging.SimpleFormatter
    
    # Set the default formatter for new ConsoleHandler instances
    java.util.logging.ConsoleHandler.level = ALL
    java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
    
    # Set the default logging level for the logger named com.mycompany
    # works if lower then ConsoleHandler.level, if higher- is ignored
    com.tr.match.Configurator.level = FINE

4. In the log we should see (we created Consumer_1 on Channel_1):

  INFO: loggerMsg
    ClientName: ChannelCallbackClient
    Severity: Info
    Text:    Received ChannelUp event on channel Channel_1
 Instance Name Consumer_1_1
 Component Version ads3.2.0.L1.linux.tis.rrg 64-bit
loggerMsgEnd

Not to my knowledge, I think we would prefer the library info reported consistently across different applications, to know what to look for. One can add, from the application code, any required custom logging.

icon clock
10 |1500

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

Click below to post an Idea Post Idea