Skip to main content
5-Regular Member
September 26, 2016
Question

How i can enhance the task to only execute the System.out.println() statements if the wt.properties entry xxxx.verbose is set to true?

  • September 26, 2016
  • 1 reply
  • 1437 views

Hello Everybody,

How to get the Get-Properties webject to retrieve the xxxxxx.verbose property from the wt.properties file?

Currently, I create tasks have several System.out.println() statements that output information to the Method Server window and log. This is desirable during development, when we frequently need to debug code. However, in production this can slow the application, waste disk space, and make the logs less readable.

Instead of deleting the output statements entirely, it would be nice if it could be switched on and off using a wt.properties entry.

How i can enhance the task to only execute the System.out.println() statements if the wt.properties entry xxxx.verbose is set to true.

1 reply

16-Pearl
November 17, 2016

Hi Shravan,

You can retrieve the property value using the Get-Properties webject or simply using the following API.

<%

String verbose = wt.util.WTProperties.getLocalProperties().getProperty("ext.myCustomVerbose");

System.out.println("Hello"+verbose);

%>

For other purposes, I would suggest using a logger as shown below to avoid MS restart.

private static final Logger log;

  static {

  try {

  log = LogR.getLogger(MyClass.class.getName());

  } catch (Exception e) {

  throw new ExceptionInInitializerError(e);

  }

  }

// usage

log.trace("Called from xyz method");

Regards,

Bhushan

5-Regular Member
November 21, 2016

Thank you Bhushan

Regards

Shravan