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

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?

Regular Member

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.

Tags (1)
2 REPLIES 2

Re: 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?

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

Re: 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?

Thank you Bhushan

Regards

Shravan

Announcements
LiveWorx Call For Papers Happening Now!