Worklight: send client logs to server

625 Views Asked by At

I am using worklight 6.1 and I'm trying to send logs that are created in my client to the server in order to be able to view the logs in case the application crashes. What I have done is (based on this link http://pic.dhe.ibm.com/infocenter/wrklight/v5r0m6/index.jsp?topic=%2Fcom.ibm.worklight.help.doc%2Fdevref%2Fc_using_client_log_capture.html):

  • Set the below in wlInitOptions.js

    logger : {
        enabled: true, 
        level: 'debug', 
        stringify: true, 
        pretty: false,
        tag: {
            level: false, 
            pkg: true
            }, 
        whitelist: [], 
        blacklist: [],
        nativeOptions: {
            capture: true
        }
    },
    
  • In the client I have set the below where I want to send a log:

    WL.Logger.error("test");
    WL.Logger.send();
    
  • Implemented the necessary adapter WLClientLogReceiver-impl.js with the log function based on the link

Unfortunately I can't see the log in the messages.log. Anyone have any ideas?

I have also tried to send the log in the analytics DB based on this link http://www-01.ibm.com/support/knowledgecenter/SSZH4A_6.2.0/com.ibm.worklight.monitor.doc/monitor/c_op_analytics_data_capture.html.

What I did is:

WL.Analytics.log( { "_activity" : "myCustomActivity" }, "My log" );

however no new entry is added in the app_Activity_Report table. Is there something I am missing?

1

There are 1 best solutions below

0
On

Couple of things:

  • Follow Idan's advice in his comments and be sure you're looking at the correct docs. He's right; this feature has changed quite a bit between versions.

  • You got 90% of the configuration, but you're missing the last little bit. Simply sending logs to your adapter is not enough for them to show in your messages.log. You need to do one of the following to get it into messages.log:

Also, WL.Analytics.log data does not go into the reports database. The only public API that populates the database is WL.Client.logActivity. I recommend sticking with the WL.Logger and WL.Analytics APIs.