1

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.

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
Michael Mirt
  • 361
  • 1
  • 3
  • 14

3 Answers3

1

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

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.

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • Thanks for the article list. I've tried these that apply, within my WL studio but they have no impact on successfully logging when using System.out.println() from Java code. Is there an available description from development why this capability is not available in the latest release? I spoke to a few folks and they are running on Mac Book, and this works (System.out.println()). I'm on Win 7. Thanks – Michael Mirt Jun 05 '13 at 19:53
  • And they use 5.0.6.1 as well? Have then set up Worklight any differently? – Idan Adar Jun 05 '13 at 20:04
  • Yes, same version of WL, and Eclipse. Followed the same install steps. Previously I had this working fine on 5.0.5, and it abruptly stopped working. I've read other posts where people have had the same experience, but have never been able to resolve. – Michael Mirt Jun 05 '13 at 21:32
  • What about my suggestion to use WL.Logger.debug/error/log? That's how you should do it in Worklight rather than System.out.println() (which, I'm told, is surprising to be working for your co-workers). Please try with WL.Logger.debug/error/log instead. – Idan Adar Jun 06 '13 at 03:17
  • @MichaelMirt, please see my updated answer - you can use logger.info/logger.warning. – Idan Adar Jul 07 '13 at 09:59
  • Sorry for neglecting to update. The only solution that corrected my issue was a re-install of Eclipse + Worklight. Once re-installed the logging wrkedas anticipted. – Michael Mirt Feb 26 '14 at 13:54
1
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.

christianmenkens
  • 790
  • 4
  • 22
  • Is this any different than using the already existing logger.warning I mentioned below...? – Idan Adar Jul 14 '13 at 11:48
  • I am not sure what you mean with "logger.warning" ... in my Adapter Java code I have no variable "logger" .. also, I have not static Java Class called "Logger" with a method "warning". – christianmenkens Jul 15 '13 at 19:49
  • 1
    I am not sure why this answer is voted down - it is the right answer. I tested it in my WL Adapters and it works fine! – christianmenkens Jul 15 '13 at 21:44
  • Should have mentioned it can be seen in action in the JavaInAdapters sample project one can get in the Getting Started page... – Idan Adar Jul 16 '13 at 02:05
  • 1
    ah. right! Thank you. It does work like that: `import java.util.logging.Logger; public class Calculator1 { private final static Logger logger = Logger.getLogger(Calculator1.class.getName()); logger.info("addTwoIntegers invoked");` – christianmenkens Jul 16 '13 at 02:54
0

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.

Stealth
  • 1,559
  • 4
  • 16
  • 34