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

Commit

Permalink
Merge pull request #17 from tsimbalar/feat/error-reporting
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tsimbalar authored Feb 28, 2019
2 parents cca014a + 3615db6 commit b623320
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '{build}'
image: Visual Studio 2017
build_script:
- ps: ./Build.ps1 -majorMinor "3.0" -patch "$env:APPVEYOR_BUILD_VERSION" -customLogger "C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- ps: ./Build.ps1 -majorMinor "4.0" -patch "$env:APPVEYOR_BUILD_VERSION" -customLogger "C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
artifacts:
- path: SerilogWeb.*.nupkg
deploy:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
using System.Web;
using System.Web.Http.ExceptionHandling;
using SerilogWeb.Classic.Extensions;

namespace SerilogWeb.Classic.WebApi
{
public class WebApiExceptionLogger : ExceptionLogger
{
public override void Log(ExceptionLoggerContext context)
{
HttpContext.Current.AddError(context.Exception);
if (context.Exception != null)
{
HttpContext.Current.AddSerilogWebError(context.Exception);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@
<Private>True</Private>
</Reference>
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
<HintPath>..\..\packages\Serilog.2.6.0\lib\net45\Serilog.dll</HintPath>
<Private>True</Private>
<HintPath>..\..\packages\Serilog.2.7.1\lib\net45\Serilog.dll</HintPath>
</Reference>
<Reference Include="SerilogWeb.Classic, Version=4.2.0.0, Culture=neutral, PublicKeyToken=9462ddd55fbc0e7f, processorArchitecture=MSIL">
<HintPath>..\..\packages\SerilogWeb.Classic.4.2.42\lib\net45\SerilogWeb.Classic.dll</HintPath>
<Private>True</Private>
<Reference Include="SerilogWeb.Classic, Version=5.0.0.0, Culture=neutral, PublicKeyToken=9462ddd55fbc0e7f, processorArchitecture=MSIL">
<HintPath>..\..\packages\SerilogWeb.Classic.5.0.48\lib\net45\SerilogWeb.Classic.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<description>Adds WebAPI exception logging to SerilogWeb.Classic</description>
<language>en-US</language>
<projectUrl>https://github.com/serilog-web/classic-webapi</projectUrl>
<licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
<license type="expression">Apache-2.0</license>
<iconUrl>https://serilog-web.github.io/pages/images/serilog-web.png</iconUrl>
<tags>serilog logging aspnet webapi</tags>
</metadata>
Expand Down
4 changes: 2 additions & 2 deletions src/SerilogWeb.Classic.WebApi/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net452" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net452" />
<package id="Serilog" version="2.6.0" targetFramework="net45" />
<package id="SerilogWeb.Classic" version="4.2.42" targetFramework="net45" />
<package id="Serilog" version="2.7.1" targetFramework="net45" />
<package id="SerilogWeb.Classic" version="5.0.48" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
<Private>True</Private>
</Reference>
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
<HintPath>..\..\packages\Serilog.2.6.0\lib\net45\Serilog.dll</HintPath>
<Private>True</Private>
<HintPath>..\..\packages\Serilog.2.7.1\lib\net45\Serilog.dll</HintPath>
</Reference>
<Reference Include="Serilog.Settings.AppSettings, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
<HintPath>..\..\packages\Serilog.Settings.AppSettings.2.1.2\lib\net45\Serilog.Settings.AppSettings.dll</HintPath>
Expand All @@ -68,9 +67,8 @@
<Reference Include="Serilog.Sinks.Trace, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
<HintPath>..\..\packages\Serilog.Sinks.Trace.2.1.0\lib\net45\Serilog.Sinks.Trace.dll</HintPath>
</Reference>
<Reference Include="SerilogWeb.Classic, Version=4.2.0.0, Culture=neutral, PublicKeyToken=9462ddd55fbc0e7f, processorArchitecture=MSIL">
<HintPath>..\..\packages\SerilogWeb.Classic.4.2.42\lib\net45\SerilogWeb.Classic.dll</HintPath>
<Private>True</Private>
<Reference Include="SerilogWeb.Classic, Version=5.0.0.0, Culture=neutral, PublicKeyToken=9462ddd55fbc0e7f, processorArchitecture=MSIL">
<HintPath>..\..\packages\SerilogWeb.Classic.5.0.48\lib\net45\SerilogWeb.Classic.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
Expand Down
4 changes: 2 additions & 2 deletions test/SerilogWeb.Classic.WebApi.Test/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
<package id="NUnit" version="2.6.4" targetFramework="net452" />
<package id="Owin" version="1.0" targetFramework="net452" />
<package id="Respond" version="1.2.0" targetFramework="net452" />
<package id="Serilog" version="2.6.0" targetFramework="net452" />
<package id="Serilog" version="2.7.1" targetFramework="net452" />
<package id="Serilog.Settings.AppSettings" version="2.1.2" targetFramework="net452" />
<package id="Serilog.Sinks.Observable" version="2.0.1" targetFramework="net452" />
<package id="Serilog.Sinks.Trace" version="2.1.0" targetFramework="net452" />
<package id="SerilogWeb.Classic" version="4.2.42" targetFramework="net452" />
<package id="SerilogWeb.Classic" version="5.0.48" targetFramework="net452" />
<package id="WebGrease" version="1.5.2" targetFramework="net452" />
</packages>

0 comments on commit b623320

Please sign in to comment.