Endatix.Api.Host
0.3.0
dotnet add package Endatix.Api.Host --version 0.3.0
NuGet\Install-Package Endatix.Api.Host -Version 0.3.0
<PackageReference Include="Endatix.Api.Host" Version="0.3.0" />
<PackageVersion Include="Endatix.Api.Host" Version="0.3.0" />
<PackageReference Include="Endatix.Api.Host" />
paket add Endatix.Api.Host --version 0.3.0
#r "nuget: Endatix.Api.Host, 0.3.0"
#addin nuget:?package=Endatix.Api.Host&version=0.3.0
#tool nuget:?package=Endatix.Api.Host&version=0.3.0
Endatix.Api.Host
Install this package to host the Endatix API - the key presentation layer of the Endatix Platform. It includes both the Public and Management APIs, providing the core interface for interacting with the Endatix Platform.
[!TIP] >Endatix Platform is an open-source data collection and management library for .NET. It is designed for building secure, scalable, and integrated form-centric applications that work with SurveyJS. Endatix empowers business users with advanced workflows, automation, and meaningful insights.
Installation:
dotnet add package Endatix.Api.Host
More Information:
For detailed installation instructions, please visit Endatix Installation Guide.
Getting Started
1. Setup Program.cs with Two-Stage Logging
Following Serilog's best practices, Endatix uses a two-stage initialization approach for logging:
using Endatix.Hosting;
using Serilog;
// Create the bootstrap logger at startup to capture early errors
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.CreateBootstrapLogger();
Log.Information("Starting Endatix API...");
try
{
// Standard ASP.NET Core startup
var builder = WebApplication.CreateBuilder(args);
// Add Endatix with default configuration
// This sets up the fully configured logger based on appsettings.json
builder.Services.AddEndatixWithDefaults(builder.Configuration);
var app = builder.Build();
app.UseEndatix();
app.Run();
return 0;
}
catch (Exception ex)
{
// Log any unhandled exceptions
Log.Fatal(ex, "Endatix API terminated unexpectedly");
return 1;
}
finally
{
// Ensure all logs are flushed
Log.CloseAndFlush();
}
2. Configure appsettings.json
Add Serilog configuration to your appsettings.json file:
{
"Serilog": {
"Using": ["Serilog.Sinks.Console", "Serilog.Sinks.File"],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"WriteTo": [
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}",
"theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Sixteen"
}
},
{
"Name": "File",
"Args": {
"path": "logs/endatix-api-.log",
"rollingInterval": "Day",
"fileSizeLimitBytes": 10485760,
"retainedFileCountLimit": 7,
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
}
],
"Enrich": ["FromLogContext", "WithMachineName", "WithThreadId"]
}
}
How Two-Stage Logging Works
Endatix uses Serilog's recommended approach for complete logging coverage:
Bootstrap Logger:
- Created immediately when the program starts
- Captures any errors during startup before the host is built
- Simple console logger for early diagnostics
Fully Configured Logger:
- Created once the host is built and configuration is loaded
- Uses all the settings from your appsettings.json
- Automatically replaces the bootstrap logger
- Provides rich logging across your entire application
Advanced Logging Configuration
You can customize logging beyond the default setup using the fluent builder API:
// Customize the bootstrap logger
builder.Services.AddEndatix(builder.Configuration)
.Logging
.ConfigureBootstrapLogger(config =>
config.MinimumLevel.Debug()
.WriteTo.Console(
outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"))
.Build();
// Add additional log sinks
builder.Services.AddEndatix(builder.Configuration)
.Logging
.ConfigureSerilog(config =>
config.WriteTo.Seq("http://localhost:5341"))
.Build();
// Add Application Insights integration
builder.Services.AddEndatix(builder.Configuration)
.Logging
.UseApplicationInsights()
.Build();
This builder pattern gives you full control over your logging configuration while maintaining the benefits of the two-stage approach.
Benefits of Two-Stage Logging
- Complete Coverage: Captures all events from the very first line of your application
- Early Error Detection: Ensures startup errors are logged, even before configuration is loaded
- Configuration Freedom: Use your appsettings.json to configure logging as needed
- Simplified Integration: Just add two blocks of code to your Program.cs
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net9.0
- Endatix.Api (>= 0.3.0)
- Endatix.Hosting (>= 0.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.