Results 1 to 2 of 2
  1. #1

    LS 4.01: how to log through SLF4j


    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);"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.


  2. #2
    Join Date
    Feb 2012
    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,

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

    these lines of code should work:

    Logger logger = LoggerFactory.getLogger("MyAdapterLogger");"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,




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 01:42 PM.