Worklight 5.0.6.1 - System.out.println() logging from Worklight adapter is not working

回眸只為那壹抹淺笑 提交于 2019-11-27 07:26:00

问题


I've installed Worklight 5.0.6.1 and when invoking Java code from my adapter I don't see the log output in the workspace\WorklightServetrHome\project\logs log files.

I'm using System.out.println(). Any advice why this worked successfully in previous releases of Worklight, and is not working in v5.0.6.1? What the property settings to allow System output from Java code in Worklight that need to be set?

FYI: Thinking it might be a bad install I re-installed a second time, and with the same result. The code prior to, and after the System.out.println() calls is executing correctly so I'm sure the statement is being executed.


回答1:


See if the following IBM Worklight Information Center articles help you out:

  • Logging and monitoring mechanisms
  • Enabling trace for adapters in an Eclipse-hosted server
  • Methods WL.Logger.debug, error, and log (logging methods for server-side code)

  • In JavaScript you can use WL.Logger

  • In Java you can use logger.info or logger.warning by importing java.util.logging.Logger

logger.info or logger.warning will be printed to the Eclipse Worklight console.
System.Out.println() is dependent on the application server you are using and is not in the control of Worklight.

This can be seen in action in the Using Java in Adapters training module from the IBM Worklight Getting Started page.




回答2:


Logger l = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); 
l.warning("Server Java: getAirportData");  

worked fine in the Eclipse WL console.

However:

l.info("Server Java: getAirportData");

did not work. Probably due to WL logging settings.




回答3:


In Mac, when I had my sample app running, I went to the "Servers" tab, expanded the Worklight Development Server. Then I right-clicked on "Server Configuration" and selected "Open". That opens your server.xml file.

There is a line like this - logging consoleLogLevel=..

You can set that consoleLogLevel to INFO or DEBUG or whatever you like to see what happens in your adapter.



来源:https://stackoverflow.com/questions/16947323/worklight-5-0-6-1-system-out-println-logging-from-worklight-adapter-is-not-w

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