Docs menu · Getting Started
DocsLlamaLogger.Core SDK

Getting Started

LlamaLogger.Core 26.1.2

Using only a few lines of code, you can start managing exceptions online. All of your exceptions will be accessible in one place with the option to receive email notifications when new exceptions arrive. To get started, follow these easy steps:

  1. Include the LlamaLogger.Core NuGet package (currently 26.1.2) in your project: dotnet add package LlamaLogger.Core
  2. Create an instance of the LlamaLoggerClient using your project API key
  3. Start logging exceptions
using LlamaLogger.Core;

string apikey = ""; //The project API key located in your Llama Logger account
string version = "1.0"; //Your application's version number

LlamaLoggerClient logger = new LlamaLoggerClient(apikey, version);

try
{
    throw new InvalidOperationException("Oops!");
}
catch(Exception ex)
{
    logger.LogError(ex);
}

logger.FlushQueue(10000); //Give queued entries up to 10 seconds to send before the app exits

Entries are sent in the background, so a short-lived app (like this console example) should flush before it exits. See Flushing the Queue.

One client per application

Create a single LlamaLoggerClient when your application starts and reuse it everywhere, for example as a singleton or a static field. Each client has its own queue and background sender, so creating one per request or per error wastes resources.

Logging levels

Besides exceptions, you can log plain text messages. Every entry has a logging level:

Level Methods
Diagnostic LogDiagnostic(string), LogDiagnostic(Exception)
Info LogInfo(string), LogInfo(Exception)
Warning LogWarning(string), LogWarning(Exception)
Error LogError(string), LogError(Exception)
Required Log(string, LoggingLevel.Required), Log(Exception, LoggingLevel.Required)
logger.LogInfo("Nightly import started");
logger.LogWarning("Import file was empty");
logger.Log(ex, LoggingLevel.Error); //Same as logger.LogError(ex)

By default every level is sent. To send only warnings and above, set a minimum level:

logger.SetLoggingLevel(LoggingLevel.Warning);

SetLoggingLevel applies to every sink on the client, including custom sinks. To pause logging entirely, call logger.EnableLogging(false).

All logging methods return immediately: entries are queued and sent on a background thread.

Supported frameworks

LlamaLogger.Core targets .NET Framework 4.6.2 and later, and .NET 6, 8, 9 and 10.

Next steps