Results 1 to 10 of 10
  1. #1

    lsClient.setLoggerProvider(loggerProvider) is not a function

    Hi,

    I'm trying to user SimpleLoggerProvider to log info from lightstreamer JS client. As i have followed the JSdoc but having weired exception which is setLoggerProvider is not a function.

    Does anyone know the reason? Thanks in advance.

    Regards
    Shabbir

  2. #2
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Hi,

    setLoggerProvider is a static method:


    HTH

  3. #3
    Quote Originally Posted by Mone View Post
    Hi,

    setLoggerProvider is a static method:


    HTH
    Hi Mone,

    Thanks for the info. But the way i'm using the logger is below,

    define("lsClient",["LightstreamerClient"],function(LightstreamerClient) {
    var lsClient = new LightstreamerClient(); lsClient.connectionDetails.setServerAddress("${PRE SSESSIONINFORMATION.pushProtocol}://${PRESSESSIONINFORMATION.pushDomain}:${PRESSESSION INFORMATION.pushPort}");
    lsClient.connectionDetails.setAdapterSet("ASADAPTE RSET");
    lsClient.connectionDetails.setUser('${PRESSESSIONI NFORMATION.sessionId}');
    lsClient.connectionDetails.setPassword('${PRESSESS IONINFORMATION.domainInstance.topLevelDomain}');
    lsClient.connectionSharing.enableSharing("auctione erScreen","ATTACH","CREATE");
    lsClient.connect();
    return lsClient;
    });

    require(["lsClient","Subscription", "StaticGrid", "SimpleLoggerProvider", "RemoteAppender", "LogMessages"],
    function(lsClient,Subscription, StaticGrid, SimpleLoggerProvider, RemoteAppender,LogMessages) {

    try
    {
    var loggerProvider = new SimpleLoggerProvider();
    lsClient.setLoggerProvider(loggerProvider);
    var myAppender = new RemoteAppender("INFO","*", lsClient);
    loggerProvider.addLoggerAppender(myAppender);

    var customLogger = loggerProvider.getLogger("*");
    customLogger.info("Test Log", null);
    .....
    .....
    .....

    lsClient.subscribe(auctionSubscription);

    }
    catch (err)
    {
    }
    });

    How can i use it here?

  4. #4
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    You can't use it that way because lsClient.setLoggerProvider does not exists. setLoggerProvider is not a property of LightstreamerClient.prototype, is a property of LightstreamerClient itself

    Check section 2.6.3 of the following document for a working example:
    http://www.lightstreamer.com/latest/...nt%20Guide.pdf



  5. #5
    Quote Originally Posted by Mone View Post
    You can't use it that way because lsClient.setLoggerProvider does not exists. setLoggerProvider is not a property of LightstreamerClient.prototype, is a property of LightstreamerClient itself

    Check section 2.6.3 of the following document for a working example:
    http://www.lightstreamer.com/latest/Lightstreamer_Allegro-Presto-Vivace_5_1_Colosseo/Lightstreamer/DOCS-SDKs/sdk_client_javascript/doc/JavaScript%20Client%20Guide.pd


    Thanks Mone, I didn't recognize that. But now having the problem with the second part when i use RemoteAppender when running lightstreamer locally (Realtime screen freezes). If i cannot test remote appender in dev env then how can i test the remote appender? Also, do you know what is the usage of the category in the getLogger? Suppose lightstreamer.stream. Do you have any example for logger in JS Client?
    Thanks in advance.

    var loggerProvider = new SimpleLoggerProvider();
    LightstreamerClient.setLoggerProvider(loggerProvid er);
    var myAppender = new ConsoleAppender("INFO","*", lsClient);
    loggerProvider.addLoggerAppender(myAppender);

    var customLogger = loggerProvider.getLogger("lightstreamer.stream");
    //var customLogger = loggerProvider.getLogger("*");
    customLogger.info("Test Log", null);
    Last edited by shabbirh; October 17th, 2013 at 11:27 AM.

  6. #6
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Hi,

    sorry for the late answer.
    The browser freeze when loggin * at INFO level because the RemoteLogger itslef exploits the internal classes of the Lightstreamer library to send the messages to the server. Doing so it triggers some more INFO log that needs to be sent and thus it starts a loop of messages: too many for the client to be handled.
    I'll evaluate what to do to fix the issue, in the meanwhile avoid the use of the RemoteLogger at INFO level and set it to ERROR. Sorry.

    As per the categories there is a description here: http://www.lightstreamer.com/docs/cl...html#getLogger

    Anyway we have open-sourced all the log layer (excluding the RemoteLogger class).
    Note that the code in the Lightstreamer library may be currently different and that you probably can't make the current library use this new project, still you can include it alongside the library if it fits your needs.
    See https://github.com/Weswit/utility-logging-javascript

  7. #7
    Quote Originally Posted by Mone View Post
    Hi,

    sorry for the late answer.
    The browser freeze when loggin * at INFO level because the RemoteLogger itslef exploits the internal classes of the Lightstreamer library to send the messages to the server. Doing so it triggers some more INFO log that needs to be sent and thus it starts a loop of messages: too many for the client to be handled.
    I'll evaluate what to do to fix the issue, in the meanwhile avoid the use of the RemoteLogger at INFO level and set it to ERROR. Sorry.

    As per the categories there is a description here: http://www.lightstreamer.com/docs/cl...html#getLogger

    Anyway we have open-sourced all the log layer (excluding the RemoteLogger class).
    Note that the code in the Lightstreamer library may be currently different and that you probably can't make the current library use this new project, still you can include it alongside the library if it fits your needs.
    See https://github.com/Weswit/utility-logging-javascript
    Hi Mone,

    Thanks for your reply. First of all, i need to send the log to lightstreamer server to log it. Therefore, ConsoleAppender is not use for my case. I'm a working with a system where we have a full production license of Lightstreamer and having several problem from customer everyday. Therefore, decided to use the lightstreamer logger, which is we thought will be reliable than other (e.g., log4javascript). Besides, when i try to use RemoteLogger with "ERROR" level, it also goes to a infinte loop to send messages. It is pity that you don't have a proper logger to log events remotely from client. Please let me know if you can fix the remote logger. Thanks.

    Regards
    Shabbir

  8. #8
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Sorry,

    That's unexpected.
    We have the RemoteLogger configured @ ERROR level on our own online demos and we've never experienced such issue.
    Can you link me an example page showing the issue or help me write a page that reproduces the issue?

    This is the code from our own demo

  9. #9
    Quote Originally Posted by Mone View Post
    Sorry,

    That's unexpected.
    We have the RemoteLogger configured @ ERROR level on our own online demos and we've never experienced such issue.
    Can you link me an example page showing the issue or help me write a page that reproduces the issue?

    This is the code from our own demo
    Hi Mone,

    Yes, that's true it doesn't go to a loop but i cannot reproduce any RemoteAppender at error level. It doesn't send log while using the same place where i have info log. Just change the level to ERROR. it works and go on a loop when i use the INFO. below the code i'm using.

    require(["lsClient","LightstreamerClient", "Subscription", "StaticGrid", "SimpleLoggerProvider", "ConsoleAppender", "LogMessages"],
    function(lsClient,LightstreamerClient, Subscription, StaticGrid, SimpleLoggerProvider, ConsoleAppender,LogMessages) {

    try
    {
    var loggerProvider = new SimpleLoggerProvider();
    LightstreamerClient.setLoggerProvider(loggerProvid er);
    var myAppender = new ConsoleAppender("INFO","*", lsClient);
    loggerProvider.addLoggerAppender(myAppender);
    var customLogger = loggerProvider.getLogger("*");
    var auctionData = new StaticGrid("astable",true);
    auctionData.setHtmlInterpretationEnabled(true);

    var auctionSubscription = new Subscription("MERGE",auctionData.extractItemList() ,schema);
    auctionSubscription.setDataAdapter("ASADAPTER");
    auctionSubscription.setRequestedSnapshot("yes");
    auctionSubscription.addListener(auctionData);

    auctionSubscription.addListener({
    onSubscription:function() {
    try
    {
    <c:choose>
    <c:when test="${PRESSESSIONINFORMATION.domainInstance.doma inId == 16}">
    customLogger.info("Successfully Subcribed to LightStreamer Server" + "#" + serverTimeStamp + "#" + clientTimeStamp + "#" + auctionserverLatency + "#" + timeServerLatency, null);
    //log.info("Successfully Subcribed to LightStreamer Server" + "#" + serverTimeStamp + "#" + clientTimeStamp + "#" + auctionserverLatency + "#" + timeServerLatency);
    </c:when>
    <c: otherwise>
    customLogger.info("Successfully Subcribed to LightStreamer Server", null);
    //log.info("Successfully Subcribed to LightStreamer Server");
    </c: otherwise>
    </c:choose>

    }catch (err)
    {
    errorHandler.logException("onSubscription(...) getting values failed.", err, null);
    }
    });
    Regards
    Shabbir
    Last edited by shabbirh; October 25th, 2013 at 11:08 AM.

  10. #10
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    If you're only interested in your own log and are not interested in the internal log of the library you could avoid the use of "*" and do something like this:




    If you need the internal log of the library at INFO level you can't use the * with the remote logger but you have to list all the categories excluding lightstreamer.subscriptions
    If you need the internal log of the library at DEBUG level other categories need to be excluded.

 

 

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 05:34 PM.