Skip to content

Commit

Permalink
Check if logger is null and throw
Browse files Browse the repository at this point in the history
Part of feedback for serilog#1002
  • Loading branch information
pardahlman committed Sep 30, 2017
1 parent 2988d20 commit 6dc8d8e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Serilog/Core/ForContextExtension.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Serilog.Events;
using System;
using Serilog.Events;

namespace Serilog
{
Expand Down Expand Up @@ -26,6 +27,9 @@ public static ILogger ForContext<TValue>(
TValue value,
bool destructureObjects = false)
{
if (logger == null)
throw new ArgumentNullException(nameof(logger));

return !logger.IsEnabled(level)
? logger
: logger.ForContext(propertyName, value, destructureObjects);
Expand Down

0 comments on commit 6dc8d8e

Please sign in to comment.