Skip to Content
Author's profile photo Former Member

Runtime Check for Server Environment

If you are using NWDI, then you must have come across the scenario where you felt like putting a logger in your code for certain check. How to write a logger specific to your environment (Dev, Qua or Prod) is the question which I want to answer via this blog.

At the time of portal installation, the profile file is generated by default, with the name Default.pfl. You can access the same by navigating to the path /usr/sap/SID/SYS/profile/

The content of the file looks something like


j2ee/dbtype = ora

j2ee/dbname = SID

j2ee/dbhost = ###



system/type = J2EE

SAPFQDN = ####



# SAP Central Service Instance for J2EE


j2ee/scs/host = ###

j2ee/scs/system = ***

j2ee/ms/port = ****

You can access these information via java code. The following piece of code shows how to retrieve all system property names and then retrieve each property using its name:-

Properties props = System.getProperties();

Enumeration pNames = props.propertyNames();

String key = “”;

while (pNames.hasMoreElements())


          key = (String) pNames.nextElement();

          System.out.println(key + “=” +props.getProperty(key));


I have not used any property other than SAPSYSTEMNAME and so not sure if you really need to know how to retrieve the complete file (as shown above).

But to identify the environment, you can just use the following piece of code-

String SID = System.getProperty(“SAPSYSTEMNAME”).toString();

If you are aware of the system names, you can use the conditional check as

if(SID.compareToIgnoreCase(“MY_SID”) == 0)



Or, you can use any of the available methods, as required.


Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.