Skip to main content
5-Regular Member
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?

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.

2 replies

16-Pearl

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

Translate
5-Regular Member

Thank you Bhushan

Regards

Shravan

Translate