public class ExceptionLogging
public class ExceptionLogging
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http.Json; using Microsoft.Extensions.DependencyInjection; /// var builder = WebApplication.CreateBuilder(args); /// // Configure JSON options if necessary (e.g., to set up property naming policies) builder.Services.Configure<JsonOptions>(options => { // Configure JSON serialization settings if needed }); /// var app = builder.Build(); /// // Define a POST endpoint for logging exceptions app.MapPost("/log-exception", (ExceptionLogging exceptionLogging) => { if (exceptionLogging == null) { return Results.BadRequest("Exception details are required."); } /// // Log the exception details. Here, we're just writing to the console for demonstration. Console.WriteLine($"ApplicationName: {exceptionLogging.ApplicationName}"); Console.WriteLine($"Message: {exceptionLogging.Message}"); Console.WriteLine($"CallingMethod: {exceptionLogging.CallingMethod}"); Console.WriteLine($"FileName: {exceptionLogging.FileName}"); Console.WriteLine($"LineNumber: {exceptionLogging.LineNumber}"); /// // Respond that the exception details have been received and logged. return Results.Ok("Exception details logged successfully."); }); /// app.Run();
System.Object
Walter.BOM.ExceptionLogging
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2