IBM Worklight 6.0 - How to enable/view WL.Logger.debug in adapters?

假如想象 提交于 2019-11-26 17:08:07

问题


I have implemented the following simple HTTP adapter in order to introduce myself to Worklight Adapters. It works correctly.

However, I can't see in the Eclipse Worklight console my WL.logger.debug statements!

I've tried to configure logging.properties and server.xml as shown in this Information Center article, but it doesn't show the debug lines (request and result).

Any suggestions?

JS:

 function currencyConvertor(data) {

            var request =
                <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                      <soap:Body>
                       <ConversionRate xmlns="http://www.webserviceX.NET/">
                          <FromCurrency>{data.fromCurrency}</FromCurrency>
                          <ToCurrency>{data.toCurrency}</ToCurrency>
                        </ConversionRate>
                       </soap:Body>
                 </soap:Envelope>;

                 WL.Logger.debug("request start ---------");
                     WL.Logger.debug(request); 
                     WL.Logger.debug("request end --------");

                 var input = {
                               method : 'post',
                               returnedContentType : 'xml',
                               path : '/CurrencyConvertor.asmx',
                               body: {
                                       content: request.toString(),
                                       contentType: 'text/xml; charset=utf-8'
                                      }
                              };

                 var result = WL.Server.invokeHttp(input);

                 WL.Logger.debug("result start ---------");
                     WL.Logger.debug(result); 
                     WL.Logger.debug("result end --------");

                 return result.Envelope.Body;
        }

回答1:


WebSphere Liberty profile does not support debug level logging in the Worklight Development Server Console view.

You can use WL.Logger.debug and edit server.xml to view the log in the trace.log file

  1. Open the Servers view in Eclipse
  2. Expend the Worklight Development Server entry
  3. Double-click on Server Configuration (server.xml)
  4. Switch to Source tab
  5. Uncomment this line: <logging traceSpecification="com.worklight.*=debug=enabled"/>
  6. After invoking your adapter procedure you will find the log at <eclipseWorkspace>\WorklightServerConfig\servers\worklight\logs\trace.log

Be sure to re-deploy the adapter before attempting to view the logs.

Alternatively,
You can use WL.Logger.warn or WL.Logger.error; these logs will display in the Worklight Development Server Console view.




回答2:


Try to use WL.Server.info() instead of .debug(). In general - see this blogpost, it explains a lot about debugging and logging https://www.ibm.com/developerworks/community/blogs/worklight/entry/logging_and_debugging_on_worklight_server?lang=en



来源:https://stackoverflow.com/questions/20493912/ibm-worklight-6-0-how-to-enable-view-wl-logger-debug-in-adapters

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