Docs menu · DevExpress XAF
DocsIntegrations

DevExpress XAF

The DevExpress eXpressApp Framework (XAF) is a powerful low-code framework for creating line-of-business applications. To make Llama Logger integration easier, the Llamachant.ExpressApp.LlamaLogger NuGet package plugs Llama Logger into XAF's built-in Tracing, so errors XAF logs are also sent to Llama Logger.

Install the package

Install Llamachant.ExpressApp.LlamaLogger in your Blazor.Server or Win project. Choose the package version that matches your DevExpress version: for example, 26.1.x for XAF 26.1 or 25.2.x for XAF 25.2.

For older XAF versions, use the legacy LlamachantFramework.LlamaLogger package. Its setup is the same.

Both packages use the namespace LlamachantFramework.LlamaLogger.

XAF Blazor applications

In Program.cs, call LlamaLoggerTracing.Setup and then LlamaLoggerTracing.Initialize() before any other tracing calls, at the start of the else block in Main:

using LlamachantFramework.LlamaLogger;

public static int Main(string[] args) {
    if(ContainsArgument(args, "help") || ContainsArgument(args, "h")) {
        // ...
    }
    else {
        // Llama Logger
        string apiKey = Environment.GetEnvironmentVariable("LlamaLoggerAPIKey");
        string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
#if DEBUG
        version += "-dev";
#endif
        LlamaLoggerTracing.Setup(apiKey, version);
        LlamaLoggerTracing.Initialize();
        LlamaLoggerTracing.Tracer.Client.AddCustomData("Machine", Environment.MachineName); // optional

        DevExpress.ExpressApp.FrameworkSettings.DefaultSettingsCompatibilityMode = DevExpress.ExpressApp.FrameworkSettingsCompatibilityMode.Latest;
        IHost host = CreateHostBuilder(args).Build();
        if(ContainsArgument(args, "updateDatabase")) {
            // ...
        }
        else {
            host.Run();
        }

        LlamaLoggerTracing.Tracer.Client.FlushQueue(10000); // send queued entries before the app exits
    }
    return 0;
}

XAF WinForms applications

The WinForms template's Program.cs already sets up Tracing. Call LlamaLoggerTracing.Setup just before that block, and change the existing Tracing calls to LlamaLoggerTracing (don't call Initialize twice):

using LlamachantFramework.LlamaLogger;

// ...
string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
#if DEBUG
version += "-dev";
#endif
LlamaLoggerTracing.Setup("<YourAPIKey>", version);

if(Tracing.GetFileLocationFromSettings() == DevExpress.Persistent.Base.FileLocation.CurrentUserApplicationDataFolder) {
    LlamaLoggerTracing.LocalUserAppDataPath = Application.LocalUserAppDataPath;
}
LlamaLoggerTracing.Initialize();
// ...

try {
    winApplication.Setup();
    winApplication.Start();
}
catch(Exception e) {
    winApplication.StopSplash();
    winApplication.HandleException(e);
}
finally {
    LlamaLoggerTracing.Tracer.Client.FlushQueue(10000); // send queued entries before the app exits
}

What gets sent

  • Errors only. Every error written through XAF's Tracing (Tracing.Tracer.LogError), by XAF or by your own code, is sent to Llama Logger. Text, values and warnings are still written to your local log file but aren't sent.
  • Your application keeps writing its normal XAF log file as well.

Customize entries

LlamaLoggerTracing.Tracer.Client is a regular LlamaLoggerClient, so every SDK feature works. For example, add custom data, attachments or ignore exception types:

LlamaLoggerTracing.Tracer.CustomizeLogEntry += (s, e) => {
    e.LogEntry.AddCustomData("Culture", System.Globalization.CultureInfo.CurrentUICulture.Name);
};

LlamaLoggerTracing.Tracer.Client.AddIgnoredExceptionType<DevExpress.Persistent.Validation.ValidationException>();

Keep your API key out of source control

The examples read the project API key from an environment variable or use a placeholder. For a Blazor app, an environment variable, Azure App Service application setting, or user secrets keep the key out of your repository. A WinForms app has to ship the key with the application, so use a key for a project dedicated to that app, and regenerate it if it leaks.