1. Introduction
Before diving into practical stuff, let's understand why external systems for collecting logs are useful at all. Imagine your app is deployed not on your home PC but in production: hundreds of servers, microservices, tons of users, someone complains that the "app is sluggish". Finding the right event in that flood of logs is like looking for a needle in a haystack. Without centralized log collection, debugging and maintaining such apps is practically impossible. That's where Seq and Application Insights come in.
Seq: nice UI, fast search, real-time
Seq is a centralized system for collecting and analyzing structured logs, tuned for .NET and Serilog. It's not just a service for dumping log files — it's a powerful tool: you see live log streams, filter, search by properties, and build alerts. Seq can be deployed locally or in the cloud.
Why choose Seq?
- Tuned for .NET and Serilog, works "out of the box".
- Incredibly fast search and filtering by any message properties.
- Simple and convenient web UI.
- Can be deployed locally without extra bureaucracy, even on a laptop.
What does a simple architecture look like?
+--------------+ +-------------+ +-------------+
| .NET-app | --(log)| Serilog | --(http)| Seq |
+--------------+ +-------------+ +-------------+
| ^
| |
(search, filters, <----[Web UI]
alerts, integrations)
The app writes structured logs via Serilog, Serilog sends them to Seq. In Seq's web UI you can do whatever you need.
2. Integrating Serilog with Seq
Installing Seq
You can quickly try Seq locally even for home experiments. For example, if you use Windows, download Seq from the official site.
- Download Seq and install it.
- After installation open the web UI (usually http://localhost:5341).
- Done! Now configure sending logs to Seq.
Integrating Serilog with Seq
Install the NuGet package:
dotnet add package Serilog.Sinks.Seq
Example logging setup in Program.cs:
using Serilog;
public class Program
{
public static void Main(string[] args)
{
// Configure Serilog to write logs to Seq
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information()
.WriteTo.Console()
.WriteTo.Seq("http://localhost:5341") // URL of your Seq server
.CreateLogger();
Log.Information("Application is starting");
// ... Rest of your app ...
Log.CloseAndFlush();
}
}
If everything is configured correctly, your app logs will start flowing into Seq.
Example structured event
Log.Information("User {User} logged in at {Time}", userName, DateTime.UtcNow);
In Seq you can now search for all logins of a specific user:
User == 'vasya'
Filtering and search
Seq can filter events by any field and value. For example, want to see all errors for today? Just set the filter:
@Level = 'Error' and @Timestamp > today()
You can combine conditions — it's really handy!
Alerts and integrations
Seq can create alerts: for example, if the error count exceeds a threshold you'll get an email, a webhook will fire, or you can even send a message to Slack.
What else can it do?
- Integration with CI/CD systems to automatically collect test logs.
- Custom Dashboards (for extra cost).
- Plugins for log analysis, automation (e.g., auto-creating bugs on failures).
- Integration with Grafana/Prometheus via plugins.
Typical mistakes when configuring Seq
One common problem is forgetting to specify the correct Seq server URL in Serilog, or the Seq server listening on a different port.
Another issue is not opening the port for incoming connections if Seq runs in Docker or on a server. Check port accessibility from the app to Seq.
3. Application Insights: telemetry for .NET, cloud and some magic
Application Insights (or "App Insights") is Microsoft's Azure cloud platform for monitoring and analyzing applications. It's not just log collection, but automatic anomaly detection, usage analytics, dependency monitoring, requests, external APIs — and of course real-time visualization. Azure Application Insights is a standard in enterprise .NET world.
What are the benefits of Application Insights?
- No separate server installation required: everything is in the cloud.
- Deep integration with .NET, ASP.NET, Azure, Visual Studio.
- Automatically collects not only your logs but metrics, exceptions, requests, SQL queries.
- Ability to build dashboards, monitor SLA, detect anomalies, analyze distributed traces (distributed tracing).
How does Application Insights work?
+--------------+ +-------------------+ +---------------------+
| .NET-app | --(SDK)| AppInsights SDK | --(https)| Azure Application |
+--------------+ +-------------------+ | Insights (cloud) |
+---------------------+
^ |
(W3C Trace +----> Analytics, search, dashboards
Context)
The app with the SDK sends telemetry to Azure cloud; you analyze and visualize it through the Azure portal web UI.
Integrating Application Insights with a .NET app
Option 1: Quick and simple
If you have an ASP.NET Core app, it's very straightforward:
dotnet add package Microsoft.ApplicationInsights.AspNetCore
In Program.cs:
builder.Services.AddApplicationInsightsTelemetry("<your_instrumentation_key>");
And if you have a console or desktop app:
dotnet add package Microsoft.ApplicationInsights
Initialization:
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Extensibility;
var telemetryConfig = TelemetryConfiguration.CreateDefault();
telemetryConfig.InstrumentationKey = "<your_instrumentation_key>";
var telemetryClient = new TelemetryClient(telemetryConfig);
telemetryClient.TrackTrace("Hello from Application Insights!");
telemetryClient.TrackException(new Exception("OOPS, an error occurred!"));
You need to get the instrumentation key from the Azure portal after creating an Application Insights resource.
How to send structured data?
You can add properties to each trace record:
telemetryClient.TrackTrace("User logged in",
new Dictionary<string, string> { ["User"] = userName }
);
Example: logging user actions
Suppose you want to log a user login:
var props = new Dictionary<string, string>
{
{ "User", userName },
{ "Time", DateTime.UtcNow.ToString("o") }
};
telemetryClient.TrackEvent("UserLogin", props);
Now not only the event but all properties are visible in the portal.
4. Useful nuances
What do you see in Application Insights?
- Application overview: logins, errors, dependencies (e.g., SQL queries).
- Log search: any events, filtering by properties.
- Visualization: charts, dashboards.
- Tracing: you can see call chains and how long each operation took.
- Alerting: setting alerts on any conditions.
Quick note on Application Insights structure
| Object | Description |
|---|---|
| Trace | String message (a regular log). |
| Event | Arbitrary event (for example, "Purchase"). |
| Exception | Information about an error/exception. |
| Dependency | External call (SQL, HTTP request, etc.). |
| Metric | Numeric measurements (e.g., counts). |
| Request | User request (for web apps). |
Example: searching for an error in Application Insights
In the Azure portal you can build a simple query (Kusto Query Language — KQL):
exceptions
| where timestamp > ago(1d)
| where outerMessage contains "Timeout"
| project timestamp, operation_Name, user_Id, outerMessage
This will show you all timeouts from the last day with details.
Limitations/nuances of Application Insights
- You need an Azure account. You can use a free tier but with limits.
- Sometimes there's a delay between sending logs and them appearing in the UI — up to a couple of minutes.
- For very private projects — it's cloud, not a local install.
- If you abuse traces too much you can quickly burn through the daily quota.
5. Comparing Seq and Application Insights
| Seq | Application Insights | |
|---|---|---|
| Where it's stored | Local server (or cloud) | Azure cloud |
| Cost | Free/paid, local | Free tier available, paid on Azure |
| Best use | .NET apps, local CI | Any apps, prod/enterprise |
| UI/Search | Very convenient, filters | Powerful, analytics, dashboards |
| Alerting | Built-in | Complex conditions, Azure integration |
| Integration | Serilog, other sinks | SDK for ASP.NET, .NET, JS, etc. |
| Flexibility | You control it | Everything under Microsoft's control |
Applying this knowledge in practice
Knowledge about Seq and Application Insights will help you not only in production but also during development and testing (for example, analyzing test behavior), when working with microservices and you want to see the whole picture. In interviews they often ask "How would you organize log collection to quickly find issues in production?" — now you have an answer!
Moreover, many modern companies use these systems to build entire DevOps chains: Continuous Delivery, automatic bug creation from alerts, etc. A logging system is not just "where Console.WriteLine goes", it's a real "black box" and monitor for your app.