EonaCat.Logger.LogClient
1.0.3
Prefix Reserved
dotnet add package EonaCat.Logger.LogClient --version 1.0.3
NuGet\Install-Package EonaCat.Logger.LogClient -Version 1.0.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EonaCat.Logger.LogClient" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EonaCat.Logger.LogClient" Version="1.0.3" />
<PackageReference Include="EonaCat.Logger.LogClient" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EonaCat.Logger.LogClient --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: EonaCat.Logger.LogClient, 1.0.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package EonaCat.Logger.LogClient@1.0.3
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EonaCat.Logger.LogClient&version=1.0.3
#tool nuget:?package=EonaCat.Logger.LogClient&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
EonaCat.Logger.LogClient
Client Installation
Via NuGet Package Manager:
dotnet add package EonaCat.Logger.LogClient
Via Package Manager Console:
Install-Package EonaCat.Logger.LogClient
📖 Usage Examples
Basic Setup
using EonaCat.Logger.LogClient;
using EonaCat.Logger.LogClient.Models;
// Configure the client
var options = new LogCentralOptions
{
ServerUrl = "https://your-logcentral-server.com",
ApiKey = "your-api-key-here",
ApplicationName = "MyAwesomeApp",
ApplicationVersion = "1.0.0",
Environment = "Production",
BatchSize = 50,
FlushIntervalSeconds = 5
};
var logClient = new LogCentralClient(options);
Integration with EonaCat.Logger
using EonaCat.Logger;
using EonaCat.Logger.LogClient.Integration;
var loggerSettings = new LoggerSettings();
loggerSettings.UseLocalTime = true;
loggerSettings.Id = "TEST";
var logger = new LogManager(loggerSettings);
// Create the adapter
var adapter = new LogCentralEonaCatAdapter(loggerSettings, logClient);
// Now all EonaCat.Logger logs will be sent to LogCentral automatically
logger.Log("Application started", LogLevel.Info);
logger.Log("User logged in", LogLevel.Info, "Authentication");
Manual Logging
// Simple log
await logClient.LogAsync(new LogEntry
{
Level = LogLevel.Information,
Category = "Startup",
Message = "Application started successfully"
});
// Log with properties
await logClient.LogAsync(new LogEntry
{
Level = LogLevel.Information,
Category = "UserAction",
Message = "User performed action",
UserId = "user123",
Properties = new Dictionary<string, object>
{
["Action"] = "Purchase",
["Amount"] = 99.99,
["ProductId"] = "prod-456"
}
});
// Log exception
try
{
// Your code
throw new Exception("Something went wrong");
}
catch (Exception ex)
{
await logClient.LogExceptionAsync(ex, "Error processing order",
new Dictionary<string, object>
{
["OrderId"] = "12345",
["CustomerId"] = "cust-789"
});
}
Security Event Logging
await logClient.LogSecurityEventAsync(
"LoginAttempt",
"Failed login attempt detected",
new Dictionary<string, object>
{
["Username"] = "admin",
["IPAddress"] = "192.168.1.100",
["Attempts"] = 5
}
);
await logClient.LogSecurityEventAsync(
"UnauthorizedAccess",
"Unauthorized API access attempt",
new Dictionary<string, object>
{
["Endpoint"] = "/api/admin/users",
["Method"] = "DELETE",
["UserId"] = "user456"
}
);
Analytics Logging
// Track user events
await logClient.LogAnalyticsAsync("PageView",
new Dictionary<string, object>
{
["Page"] = "/products/electronics",
["Duration"] = 45.2,
["Source"] = "Google"
}
);
await logClient.LogAnalyticsAsync("Purchase",
new Dictionary<string, object>
{
["ProductId"] = "prod-123",
["Price"] = 299.99,
["Category"] = "Electronics",
["PaymentMethod"] = "CreditCard"
}
);
await logClient.LogAnalyticsAsync("FeatureUsage",
new Dictionary<string, object>
{
["Feature"] = "DarkMode",
["Enabled"] = true,
["Platform"] = "iOS"
}
);
ASP.NET Core Integration
// Program.cs or Startup.cs
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Register LogCentral
var logCentralOptions = new LogCentralOptions
{
ServerUrl = builder.Configuration["LogCentral:ServerUrl"],
ApiKey = builder.Configuration["LogCentral:ApiKey"],
ApplicationName = "MyWebApp",
ApplicationVersion = "1.0.0",
Environment = builder.Environment.EnvironmentName
};
var logClient = new LogCentralClient(logCentralOptions);
builder.Services.AddSingleton(logClient);
var app = builder.Build();
// Use middleware to log requests
app.Use(async (context, next) =>
{
var requestId = Guid.NewGuid().ToString();
await logClient.LogAsync(new LogEntry
{
Level = LogLevel.Information,
Category = "HTTP",
Message = $"{context.Request.Method} {context.Request.Path}",
RequestId = requestId,
Properties = new Dictionary<string, object>
{
["Method"] = context.Request.Method,
["Path"] = context.Request.Path.Value,
["QueryString"] = context.Request.QueryString.Value
}
});
await next();
});
app.Run();
}
}
Windows Service / Console App
using EonaCat.Logger.LogClient;
using Microsoft.Extensions.Hosting;
public class Worker : BackgroundService
{
private readonly LogCentralClient _logClient;
public Worker(LogCentralClient logClient)
{
_logClient = logClient;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
await _logClient.LogAsync(new LogEntry
{
Level = LogLevel.Information,
Category = "Service",
Message = "Worker service started"
});
while (!stoppingToken.IsCancellationRequested)
{
try
{
// Your work here
await Task.Delay(1000, stoppingToken);
}
catch (Exception ex)
{
await _logClient.LogExceptionAsync(ex, "Error in worker");
}
}
await _logClient.FlushAndDisposeAsync();
}
}
WPF / WinForms Application
public partial class MainWindow : Window
{
private readonly LogCentralClient _logClient;
public MainWindow()
{
InitializeComponent();
_logClient = new LogCentralClient(new LogCentralOptions
{
ServerUrl = "https://logs.mycompany.com",
ApiKey = "your-api-key",
ApplicationName = "MyDesktopApp",
ApplicationVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(),
Environment = "Production"
});
Application.Current.DispatcherUnhandledException += OnUnhandledException;
}
private async void OnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
await _logClient.LogExceptionAsync(e.Exception, "Unhandled exception in UI");
e.Handled = true;
}
protected override async void OnClosing(CancelEventArgs e)
{
await _logClient.FlushAndDisposeAsync();
base.OnClosing(e);
}
}
🎯 Advanced Features
Correlation IDs for Distributed Tracing
var correlationId = Guid.NewGuid().ToString();
await logClient.LogAsync(new LogEntry
{
Level = LogLevel.Information,
Category = "OrderProcessing",
Message = "Order created",
CorrelationId = correlationId,
Properties = new Dictionary<string, object> { ["OrderId"] = "12345" }
});
// In another service
await logClient.LogAsync(new LogEntry
{
Level = LogLevel.Information,
Category = "PaymentProcessing",
Message = "Payment processed",
CorrelationId = correlationId, // Same ID
Properties = new Dictionary<string, object> { ["Amount"] = 99.99 }
});
Performance Monitoring
var stopwatch = Stopwatch.StartNew();
try
{
// Your operation
await SomeSlowOperation();
}
finally
{
stopwatch.Stop();
await logClient.LogAsync(new LogEntry
{
Level = LogLevel.Information,
Category = "Performance",
Message = "Operation completed",
Properties = new Dictionary<string, object>
{
["Operation"] = "DatabaseQuery",
["DurationMs"] = stopwatch.ElapsedMilliseconds,
["Status"] = "Success"
}
});
}
📊 Dashboard Features
- Real-time monitoring: Auto-refreshes every 30 seconds
- Advanced search: Full-text search across all log fields
- Filtering: By application, environment, level, date range
- Charts: Visual representation of log levels and trends
- Export: Download logs as CSV or JSON
- Alerts: Configure notifications for critical events (planned)
🔒 Security Best Practices
- Use HTTPS for production deployments
- Rotate API keys regularly
- Limit API key permissions by application
- Store API keys in secure configuration (Azure Key Vault, AWS Secrets Manager)
- Enable authentication for dashboard access (add authentication middleware)
🚀 Deployment
Docker Deployment
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "EonaCat.Logger.LogServer.dll"]
Azure Deployment
az webapp create --resource-group MyResourceGroup --plan MyPlan --name logcentral --runtime "DOTNETCORE:8.0"
az webapp deployment source config-zip --resource-group MyResourceGroup --name logcentral --src logcentral.zip
📈 Scalability
For high-volume applications:
- Use Redis for caching
- Implement Elasticsearch for faster searches
- Use message queues (RabbitMQ, Azure Service Bus) for async processing
- Partition database by date ranges
- Implement log archival and retention policies
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- EonaCat.Logger (>= 1.5.4)
- System.Net.Http.Json (>= 10.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.