Singleton Theory Components - SingletonTheory/SingletonTheory.github.io GitHub Wiki

MongoDB: Getting Started

Download MongoDB

Download Site

Unzip & Configure

  1. Unzip MongoDB to the folder of choice.
  2. Open the folder
  3. Create a Data folder
  4. Create a batch file with the following command in it: bin\mongod.exe --dbpath <DataFolder>
  5. Replace with your chosen Data folder name from step 3
  6. Run batch file.

Further Reading

Singleton Theory Logging

Description

Every API needs logs to be written and this means that a few decisions needs to be made. Decisions that could potentially make it difficult to change providers later on. In the Services our Logger need to be easily switchable and to enable this ServiceStack has a way of separating your Logging provider from your implementation by way of the LogManager. ServiceStack also makes a ditinction between two types of logging as defined in the following section.

Two Types of Logging

Inline Logging

Inline logging is enabled by way of the LogManager which is hooked up in the AppHost. This allows you to enable the logging provider of your choice as defined in their documentation. Currently the following providers are supported:

  • NLog
  • Elmah
  • Log4Net
  • Log4Netv129
  • EventLog
  • EnterpriseLibrary

Our choice at this stage is Log4Net seeing that it is currently the standard in the .Net community.

Request Logging

The RequestLogger logs all requests and responses by way of the IRequestLogger. ServiceStack has a built-in provider [RequestLogsFeature] for this and allows your hook your own up by way of implementing the interface. This is injected by using the Plugins library of ServiceStack as defined in their documentation.

Viewing Request Logs

Once the Requst Logs are configured they can be viewed at the following routes: [api/requestlogs]

External Resources

Further Reading

https://github.com/ServiceStack/ServiceStack.Logging

Singleton Theory Profiling

Description

By enabling profiling we have a chance to view our api requests and long they take. To do this the following lines was added to the Global.asax:

protected void Application_BeginRequest(object src, EventArgs e)
{
	if (Request.IsLocal)
		Profiler.Start();
}

protected void Application_EndRequest(object src, EventArgs e)
{
	Profiler.Stop();
}

Further Information

For further information I would recommend the following:

⚠️ **GitHub.com Fallback** ⚠️