Browsing articles in "rib"
Sep 22, 2008

Using ILogSupport for your Server Object Extension

Following on from my last post I thought I’d touch quickly on using the in built logging functionality of ArcGIS Server. This post is within the context of Server Object Extensions (SOE).

When using SOE’s you implement a number of interfaces:

  • ESRI.ArcGIS.esriSystem.IObjectConstruct
  • ESRI.ArcGIS.Server.IServerObjectExtension
  • ESRI.ArcGIS.esriSystem.ILogSupport

There are a number of other classes which implement ILogSupport more info here  Typically you may wish to initialise a local log object and this can be done via the InitLogging method of the ILogSupport Interface

private ESRI.ArcGIS.esriSystem.ILog2 m_log;
 
public void InitLogging(ESRI.ArcGIS.esriSystem.ILog Log)
{
m_log = (ESRI.ArcGIS.esriSystem.ILog2)Log;
}

Note that I am using the ILog2 Interface as it offers a little bit more than ILog – so i have to cast one to the other.

Ok now i have my local log object I can fire entries into the log as needed -  When my SOE initialises I create a set of objects ready for use by the SOE methods, AGS automatically logs server object construction within the server log, so strictly speaking this is not really a good example, but it illustrates the point hopefully.

public void Construct(ESRI.ArcGIS.esriSystem.IPropertySet props)
{
...
m_log.AddMessageEx(3, "LrsServerObjectExt.Construct", 110000, 0.0, "SOE objects initialised sucessfully");
..
}

So at the end of the Construct() method on the SOE I create an entry into the log. I’m using a message code out of range of the ESRI codes (110000) and i’m logging an information message using the message type 3 – (error:1, warning:2, info:3, detailed:4, debug:5).

Now that the log has been made I can validate this using the AGS Manager application – which has an improved interface for viewing logs at version 9.3:

ArcGIS Server Manager

Easy.

Pages:«123