Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit b623320

Browse files
authored
Merge pull request #17 from tsimbalar/feat/error-reporting
Use `HttpContext.AddSerilogWebError` (introduced in *SerilogWeb.Classic* v5.0) instead of `HttpContext.AddError` to store the exception to be logged. This should get rid of all the strange effects that touching HttpContext errors can cause, specially with IIS and custom errors.
2 parents cca014a + 3615db6 commit b623320

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '{build}'
22
image: Visual Studio 2017
33
build_script:
4-
- ps: ./Build.ps1 -majorMinor "3.0" -patch "$env:APPVEYOR_BUILD_VERSION" -customLogger "C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
4+
- ps: ./Build.ps1 -majorMinor "4.0" -patch "$env:APPVEYOR_BUILD_VERSION" -customLogger "C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
55
artifacts:
66
- path: SerilogWeb.*.nupkg
77
deploy:
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
using System.Web;
22
using System.Web.Http.ExceptionHandling;
3+
using SerilogWeb.Classic.Extensions;
34

45
namespace SerilogWeb.Classic.WebApi
56
{
67
public class WebApiExceptionLogger : ExceptionLogger
78
{
89
public override void Log(ExceptionLoggerContext context)
910
{
10-
HttpContext.Current.AddError(context.Exception);
11+
if (context.Exception != null)
12+
{
13+
HttpContext.Current.AddSerilogWebError(context.Exception);
14+
}
1115
}
1216
}
1317
}

src/SerilogWeb.Classic.WebApi/SerilogWeb.Classic.WebApi.csproj

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@
4242
<Private>True</Private>
4343
</Reference>
4444
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
45-
<HintPath>..\..\packages\Serilog.2.6.0\lib\net45\Serilog.dll</HintPath>
46-
<Private>True</Private>
45+
<HintPath>..\..\packages\Serilog.2.7.1\lib\net45\Serilog.dll</HintPath>
4746
</Reference>
48-
<Reference Include="SerilogWeb.Classic, Version=4.2.0.0, Culture=neutral, PublicKeyToken=9462ddd55fbc0e7f, processorArchitecture=MSIL">
49-
<HintPath>..\..\packages\SerilogWeb.Classic.4.2.42\lib\net45\SerilogWeb.Classic.dll</HintPath>
50-
<Private>True</Private>
47+
<Reference Include="SerilogWeb.Classic, Version=5.0.0.0, Culture=neutral, PublicKeyToken=9462ddd55fbc0e7f, processorArchitecture=MSIL">
48+
<HintPath>..\..\packages\SerilogWeb.Classic.5.0.48\lib\net45\SerilogWeb.Classic.dll</HintPath>
5149
</Reference>
5250
<Reference Include="System" />
5351
<Reference Include="System.Core" />

src/SerilogWeb.Classic.WebApi/SerilogWeb.Classic.WebApi.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<description>Adds WebAPI exception logging to SerilogWeb.Classic</description>
88
<language>en-US</language>
99
<projectUrl>https://github.com/serilog-web/classic-webapi</projectUrl>
10-
<licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
10+
<license type="expression">Apache-2.0</license>
1111
<iconUrl>https://serilog-web.github.io/pages/images/serilog-web.png</iconUrl>
1212
<tags>serilog logging aspnet webapi</tags>
1313
</metadata>

src/SerilogWeb.Classic.WebApi/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
66
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net452" />
77
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net452" />
8-
<package id="Serilog" version="2.6.0" targetFramework="net45" />
9-
<package id="SerilogWeb.Classic" version="4.2.42" targetFramework="net45" />
8+
<package id="Serilog" version="2.7.1" targetFramework="net45" />
9+
<package id="SerilogWeb.Classic" version="5.0.48" targetFramework="net45" />
1010
</packages>

test/SerilogWeb.Classic.WebApi.Test/SerilogWeb.Classic.WebApi.Test.csproj

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@
5555
<Private>True</Private>
5656
</Reference>
5757
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
58-
<HintPath>..\..\packages\Serilog.2.6.0\lib\net45\Serilog.dll</HintPath>
59-
<Private>True</Private>
58+
<HintPath>..\..\packages\Serilog.2.7.1\lib\net45\Serilog.dll</HintPath>
6059
</Reference>
6160
<Reference Include="Serilog.Settings.AppSettings, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
6261
<HintPath>..\..\packages\Serilog.Settings.AppSettings.2.1.2\lib\net45\Serilog.Settings.AppSettings.dll</HintPath>
@@ -68,9 +67,8 @@
6867
<Reference Include="Serilog.Sinks.Trace, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
6968
<HintPath>..\..\packages\Serilog.Sinks.Trace.2.1.0\lib\net45\Serilog.Sinks.Trace.dll</HintPath>
7069
</Reference>
71-
<Reference Include="SerilogWeb.Classic, Version=4.2.0.0, Culture=neutral, PublicKeyToken=9462ddd55fbc0e7f, processorArchitecture=MSIL">
72-
<HintPath>..\..\packages\SerilogWeb.Classic.4.2.42\lib\net45\SerilogWeb.Classic.dll</HintPath>
73-
<Private>True</Private>
70+
<Reference Include="SerilogWeb.Classic, Version=5.0.0.0, Culture=neutral, PublicKeyToken=9462ddd55fbc0e7f, processorArchitecture=MSIL">
71+
<HintPath>..\..\packages\SerilogWeb.Classic.5.0.48\lib\net45\SerilogWeb.Classic.dll</HintPath>
7472
</Reference>
7573
<Reference Include="System" />
7674
<Reference Include="System.Data" />

test/SerilogWeb.Classic.WebApi.Test/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
<package id="NUnit" version="2.6.4" targetFramework="net452" />
3737
<package id="Owin" version="1.0" targetFramework="net452" />
3838
<package id="Respond" version="1.2.0" targetFramework="net452" />
39-
<package id="Serilog" version="2.6.0" targetFramework="net452" />
39+
<package id="Serilog" version="2.7.1" targetFramework="net452" />
4040
<package id="Serilog.Settings.AppSettings" version="2.1.2" targetFramework="net452" />
4141
<package id="Serilog.Sinks.Observable" version="2.0.1" targetFramework="net452" />
4242
<package id="Serilog.Sinks.Trace" version="2.1.0" targetFramework="net452" />
43-
<package id="SerilogWeb.Classic" version="4.2.42" targetFramework="net452" />
43+
<package id="SerilogWeb.Classic" version="5.0.48" targetFramework="net452" />
4444
<package id="WebGrease" version="1.5.2" targetFramework="net452" />
4545
</packages>

0 commit comments

Comments
 (0)