This project is read-only.


There are several good and bad ways of storing your configuration in and around SharePoint.

Method Result
Hard Coded very bad - that's like no configuration at all!
web.config better but still very bad at large farms, even when used with SPWebConfigModification
SP Lists ok, but you have to define where to store (Web, Site, WebApp?) it and save that link somehwere...
SPPersistedObject ok, but quite complex. you have to create your own object for every application, and sometimes Update Conflicts in large farms will happen if not done correctly
Sponge awesome! stores your configs in the Central Admin and makes it accessible via API and Web Services!

Sponge creates a Site with multiple lists in your Central Administration http://myadmin/Sponge:

  • ConfigApplications: The name's of your applications you want to configure. This gives you a nice grouping of the config entries later on!
  • ConfigItems: This is where the actual config goes to. Add your Key/Value pairs to your application and you are ready to go!


At first, you have to decide which application you want to configure - is it an application that "lives" on SharePoint e.g. WebPart, Timer Job, etc. or is it a client application like WinForms or even an Windows Phone App!

Obviously, Sponge has to be installed on your SharePoint Farm first. See the Installation part of this readme!

  • At first you have to create a Config Application. To do this, go to the Central Administration and Click Config Applications and add an item with your desired app name.

alt text

  • Now go to the Config Items list and start adding your configuration. Example:

alt text

That's it. The configuration for Sponge Log Viewer has been set up and you now can retrieve it with the server- or client side API.

Server Side

In order to use the server side API reference Sponge.dll and add using Sponge.Logging; to your usings.

public void GetConfigServerSideOnline()
        //gets the config from central admin
	var cfg = ConfigurationManager.GetOnline("Sponge Log Viewer");
        //gets the config from site collection
        var cfg = ConfigurationManager.GetOnline("http://demo", "Sponge Log Viewer");

	//print out all items from the configuration
	foreach(var entry in cfg.Items) 
             Console.WriteLine("{0} - {1}", entry.Key, entry.Value);
        //get the value of MyKey as integer
        int a = cfg.Get<int>("MyKey");

Client Side

In order to use the server side API reference Sponge.Client.dll and add using Sponge.Client.Logging; to your usings.

public void GetConfigClientSide()
        //url to the Site Collection
        var spongeUrl = "http://demo";

        //name of the app in sharepoint
        var app = "Sponge Log Viewer";

        //whether the ClientConfigurationManager should retrieve the log config from central admin (true) or from the relative Sponge Admin Page (false)
        //relative means --> "http://demo/Sponge" --> Sponge Logging & Configuration Component Feature has to be enabled in this Site Collection
        var central = false;

        //create the logger instance
	var cfg= ClientConfigurationManager.GetOnline(spongeUrl, app, central);
        //print out all items from the configuration
	foreach(var entry in cfg.Items) 
             Console.WriteLine("{0} - {1}", entry.Key, entry.Value);

The Sponge JavaScript API allows you to use the configuration component of Sponge in JavaScript. If you want to use the js API in a page where the Sponge Logging & Configuration Component Feature is not enabled (it will automatically inject sponge.js in every page), simply reference the _layouts/Sponge/scripts/sponge.js file.

The js API also supports Central & Relative installation, just like the rest of the API does.

Note: To make the js API work, you have to configure the Sponge Logging Web Service application in your (central/relative) admin site. It is automatically added on installation and will log to the ULS log. If that is fine with you, leave it like this, otherwise configure a different target. However, do not delete this application, otherwise the js api will fail.

//this will call the central admin site, if you want to retrieve the config from relative site, use this:
//sponge.config.init("MyAppName", "http://demo", function () { ... });
sponge.config.init("MyAppName", null, function() {
   //this fires when the configuration has been loaded

   //get the config name
   var name =;

   //get the value of key 'Key1'
   var myvalue = sponge.config.get('Key1');

Supported API

Server Side

  • GetOnline(string appName): This gets the config for the specified appName from Sponge Central Admin.

  • GetOnline(string siteCollUrl, string appName): This ges the config from the specified siteCollectionUrl. Note:Sponge Logging & Configuration Component Feature has to be enabled in this Site Collection.

Client Side

  • GetOnline(string siteCollUrl, string loggerName, bool central): This gets the config from either Sponge Central Admin (central = true) or from siteCollUrl's Sponge Admin (central = false) Site. NoteSponge Logging & Configuration Component Featurehas to be enabled in this Site Collection.

Last edited Aug 9, 2013 at 6:49 AM by int32at, version 1


No comments yet.