Java ClassicEnvUtil-class And Method Code Example


Here is an example of how you can use the ClassicEnvUtil class from the logback.classic package:

import ch.qos.logback.classic.util.ClassicEnvUtil;

public class MyClass {
  public static void main(String[] args) {
    String value = ClassicEnvUtil.getSystemProperty("propertyName");
    if (value != null) {
      // do something with the value of the system property
    }
  }
}

The ClassicEnvUtil.getSystemProperty method retrieves the value of the system property with the given name. If the property is not defined, the method returns null.

You can also use the ClassicEnvUtil class to set system properties using the setSystemProperty method:

import ch.qos.logback.classic.util.ClassicEnvUtil;

public class MyClass {
  public static void main(String[] args) {
    ClassicEnvUtil.setSystemProperty("propertyName", "propertyValue");
  }
}