2

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;
        }
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
Cisco
  • 532
  • 1
  • 8
  • 24
  • You mention only editing logging.properties... did you also follow the second part in the IC article, titled "Changing the Worklight Console Server console logging levels"? Make sure you did that too, otherwise you won't see your log lines. You also do not mention where you can to view these log lines... – Idan Adar Dec 10 '13 at 12:34
  • Yes, I did. I can't view these log lines. I expect to see them in the Worklight Console in Eclipse. – Cisco Dec 10 '13 at 12:49
  • Currently I can only see: [2013-12-10 13:48:25] Starting procedure invocation on Worklight Server [2013-12-10 13:48:25] Not deploying adapter 'soapAdapter' since it was not changed since last deployment [2013-12-10 13:48:25] Invoking procedure: 'currencyConvertor' of adapter 'soapAdapter' [2013-12-10 13:48:25] Server host: 10.87.153.152 [2013-12-10 13:48:25] Server port: 10080 [2013-12-10 13:48:25] Parameters: [{"fromCurrency":"AWG", "toCurrency":"AUD"}] [2013-12-10 13:48:25] Procedure invocation finished – Cisco Dec 10 '13 at 12:50
  • 1
    No, log lines do not display in the Worklight Console in Eclipse. They display in the Worklight Development Server Console view. You need to change to the Console view and then in it switch to the server console. See my answer below. – Idan Adar Dec 10 '13 at 13:29

2 Answers2

8

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.

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
1

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

Anton
  • 3,166
  • 1
  • 13
  • 12