How to restrict the Elektron EMA API level logging in my Java class

Best Answer

  • Olivier DAVANT
    Answer ✓

    Hi @Chaitanya.Vishnubhotla

    As explained in the EMA Developers guide (6.1 - EMA Logger
    Usage), EMA uses the SLF4J logging API. Thanks to SLF4J, you can have the
    underlying logging back-end that you want. For example: The Java standard logger utility package
    (java.util.logging), log4j, or other logger adapters which implement the SLF4J
    logging interface.

    In your case, as you probably did not set any adapter, SLF4J
    prints messages on the console. A quick and easy solution for you would be to use the JDK build-in logging utility by setting it on the
    java command line. As an example: If you use the example100__MarketPrice__Streaming.bat file to run your application, you could add “-Djava.util.logging.config.file=.\logging.properties
    as a new parameter of the java command (last line of the .bat file) and provide “logging.properties” configuration file (see below) along with your application.

    Here is an example of the java command with all parameters:

    %JAVA_BIN% -Djava.util.logging.config.file=.\logging.properties
    -cp %CLASSPATH% com.thomsonreuters.ema.examples.training.consumer.series100.example100__MarketPrice__Streaming.Consumer

    Here is an example of logging.properties file with console and file logs deactivated:

    #This file contains log configuration for java logging API.
    # Level mapping between jdk and slf4j logging
    # jdk.util.logging SLF4J
    # FINEST -> ALL
    # FINEST -> DEBUG
    # FINEST -> TRACE
    # INFO -> INFO
    # WARNING -> WARN
    # SEVERE -> ERROR
    .level=ALL
    #handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler
    #handlers=java.util.logging.FileHandler
    java.util.logging.ConsoleHandler.level=WARNING
    java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
    java.util.logging.FileHandler.level=WARNING
    java.util.logging.FileHandler.pattern=./emaj.log
    java.util.logging.FileHandler.limit=50000000
    java.util.logging.FileHandler.count=20
    java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
    # Format timestamp as date/time with millisecond
    java.util.logging.SimpleFormatter.format=%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS.%1$tL %4$-7s %2$s %n%5$s

Answers

  • Hi @Chaitanya.Vishnubhotla

    Can you please expand on your requirement - so that we can provide the most relevant answer? It is not currently entirely clear what exactly you want to achieve.

  • Hi @umer.nalla,

    We are developing our own application based on the example given in program

    com.thomsonreuters.ema.examples.training.consumer.series100.example102__MarketPrice__Snapshot

    consumer = EmaFactory.createOmmConsumer(config.host(host+":"+port).username(userId));

    We are doing our custom logging, but when the above statement in italics and bold is encountered, EMA API level logging is being logged over the console as below

    May 02, 2017 3:08:06 PM com.thomsonreuters.ema.access.ConfigErrorTracker log

    INFO: loggerMsg

    ClientName: EmaConfig

    Severity: Info

    Text: reading configuration file [EmaConfig.xml] from [C:\Users\cvishnu\workspace\prreu]

    loggerMsgEnd

    May 02, 2017 3:08:06 PM com.thomsonreuters.ema.access.ChannelCallbackClient reactorChannelEventCallback

    INFO: loggerMsg

    ClientName: ChannelCallbackClient

    Severity: Info

    Text: Received ChannelUp event on channel Channel_1

    Instance Name Consumer_1_1

    Component Version ads3.0.6.L1.linux.tis.rrg 64-bit

    loggerMsgEnd

    We want to restrict this EMA API level logging, that is we don't want to get this logging appear.

    Request you to please help us here

  • Hi @Chaitanya.Vishnubhotla

    As mentioned in the EMA Java Dev Guide, it uses SLF4J logging API and therefore you could change the Logger level via a logging.properties file to WARNING or ERROR to avoid seeing INFO level outputs - or redirect the output a file instead.

    There is a sample logging.properties file in the Ema\Src\main\resource folder which you could copy, amend and use for your application.