Thursday, June 23, 2011

Writing to the server log from a java service.

If you are trying to debug a java service, you can write directly to server.log on the Integration Server.

Use this call in your java service like you would use System.err.println()

com.wm.util.JournalLogger.log(3,90,3,"LOG " + message );


It looks like the numbers make the log error code look like this:
[ISP.0090.0003I]

Very handy, just don't forget to take them out!

2 comments:

  1. I'd recommend wrapping up that call in a static method.. The numbers mean functional areas, so have to be a bit careful you aren't pretending your logging is coming from, say, the scheduler or JDBC Adapter..

    Or alternatively you can wrap up the call to invoke pub.flow:debugLog if the numbers are confusing (generate via selecting pub.flow:debugLog and "generate code -> for invoking from a service") which is not too bad a solution either.

    Either way: stick it in a shared method so that it is available to all the java services in that folder.

    ReplyDelete
  2. Hi Kevin, thanks for the hint! I've decided to go with Nathan's suggestion and posted an implemenation of it on my blog: Logging to webMethod’s Integration Server log from a Java Service.

    ReplyDelete