Worklight: send client logs to server

我只是一个虾纸丫 提交于 2020-01-06 19:50:36

问题


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:


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:

    • set audit="true" attribute in the <procedure> tag of the WLClientLogReceiver.xml file, or
    • log the uploaded data explicitly in your adapter implementation. Beware, however, that the WL.Logger API on the server is subject to the application server level configuration.

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.



来源:https://stackoverflow.com/questions/26808706/worklight-send-client-logs-to-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!