cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

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?

sghongade-3
6-Contributor

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 2
BhushanNehe
14-Alexandrite
(To:sghongade-3)

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

Thank you Bhushan

Regards

Shravan

Top Tags