Results 1 to 2 of 2
  1. #1

    LS 4.01: how to log through SLF4j

    Hi,

    how does one log through LS from a Java Adapter using the plain Slf4j API so that the log lines goes with LS's ones?

    As far as I understood, Adapters don't run in a different classloader, so the share the SLF4J runtime. Thus just doing a:

    Logger logger = LoggerFactory.getLogger(MyMetaAdapter.class);
    logger.info("Blah blah");

    would make Blah Blah appear in LS's Logback-handled log.

    It's not so for me unfortunately. I'm trying with a very simple, empty adapter written for the purpose, just to eliminate obscure behaviours from other pieces of software.

    What's the official way to log in adapters?

    This is in LightStreamer 4.01.


    Gabriele

  2. #2
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    541
    Hi Gabriele,

    I confirm you that your Adapter code (if it is java inprocess) can share the loggging configuration with the server. After adding the "MyAdapterLogger" logger in the lighstreamer_log_conf.xml configuration file,

    Code:
      <logger name="MyAdapterLogger" level="INFO">
        <appender-ref ref="LSDailyRolling" />
      </logger>

    these lines of code should work:

    Code:
    Logger logger = LoggerFactory.getLogger("MyAdapterLogger");
    logger.info("Bye Bye.");
    Alternatively, you can base your Adapter's code on log4j. Since the Lightstreamer Server uses logback for its own logging then the two logs cannot be merged unless some bridge is set up.
    For instance you can use log4j-over-slf4j.jar in place of log4j.jar. removing all "log_config" parameters from the Adapter configuration, and adding the adapter specific logger to the xml log configuration of Lighstreamer server.
    This loggers will share the logging configuration with the Server through the log4j-over-slf4j bridge.

    Hope that help,
    Giuseppe

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 08:41 PM.