Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Exceptionless;
using Microsoft.AspNetCore.Mvc;

namespace ExceptionlessClient.Controllers;
namespace ExceptionlessDemo.Controllers;

[Route("api/[controller]")]
[ApiController]
Expand Down Expand Up @@ -31,14 +31,14 @@ public void ManualException()
[Route("logs")]
public void Logs()
{
Exceptionless.ExceptionlessClient.Default.SubmitLog("Logging a message.");
ExceptionlessClient.Default.SubmitLog("Logging a message.");
}

[HttpGet]
[Route("feature")]
public void Feature()
{
Exceptionless.ExceptionlessClient.Default.SubmitFeatureUsage("FeatureName");
ExceptionlessClient.Default.SubmitFeatureUsage("FeatureName");
}

[HttpGet]
Expand All @@ -59,7 +59,7 @@ public void CustomStack()
[Route("dataexclusion")]
public void DataExclusion()
{
Exceptionless.ExceptionlessClient.Default.Configuration.AddDataExclusions("password", "*email*");
ExceptionlessClient.Default.Configuration.AddDataExclusions("password", "*email*");

try
{
Expand All @@ -77,7 +77,7 @@ public void DataExclusion()
[Route("loglevel")]
public void LogLevel()
{
Exceptionless.ExceptionlessClient.Default.SubmitLog(
ExceptionlessClient.Default.SubmitLog(
"Your log message here",
Exceptionless.Logging.LogLevel.Trace);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net11.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Exceptionless.AspNetCore" Version="6.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="Exceptionless.AspNetCore" Version="6.2.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="11.0.0" />
</ItemGroup>

</Project>

This file was deleted.

15 changes: 8 additions & 7 deletions dotnet-logging/Exceptionless/ExceptionlessTestClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddExceptionless();
builder.Services.AddOpenApi();
builder.Services.AddProblemDetails();
builder.AddExceptionless();

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
app.MapOpenApi();
}

app.UseExceptionHandler();
app.UseExceptionless();

app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.UseExceptionless();

app.Run();
app.Run();
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"launchBrowser": false,
"applicationUrl": "https://localhost:7256;http://localhost:5215",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System.Net;
using Exceptionless;
using Exceptionless.Models;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;

namespace Tests;

public class ExceptionlessCaptureTest : IClassFixture<WebApplicationFactory<Program>>
{
private readonly WebApplicationFactory<Program> _factory;

public ExceptionlessCaptureTest(WebApplicationFactory<Program> factory)
{
_factory = factory.WithWebHostBuilder(builder =>
{
builder.UseSetting("Exceptionless:ApiKey", "LOCAL_TEST_KEY_NOT_REAL");
builder.UseSetting("Exceptionless:ServerUrl", "http://localhost:9");
});
}

[Fact]
public async Task GivenGetEndpoint_WhenItThrows_ThenExceptionlessCapturesAnErrorEvent()
{
var captured = new List<Event>();
EventHandler<EventSubmittingEventArgs> handler = (_, e) =>
{
captured.Add(e.Event);
e.Cancel = true;
};

ExceptionlessClient.Default.SubmittingEvent += handler;
try
{
var client = _factory.CreateClient();
var response = await client.GetAsync("/api/values");

Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
Assert.Contains(captured, e => e.Type == Event.KnownTypes.Error);
}
finally
{
ExceptionlessClient.Default.SubmittingEvent -= handler;
}
}
}
11 changes: 6 additions & 5 deletions dotnet-logging/Exceptionless/Tests/Tests/Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net11.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand All @@ -10,13 +10,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="11.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.12.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="4.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="10.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using ExceptionlessClient.Controllers;
using ExceptionlessDemo.Controllers;

namespace Tests;

Expand Down
Loading