Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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
8 changes: 7 additions & 1 deletion 8 src/NLog/Layouts/JSON/JsonAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
namespace NLog.Layouts
{
using System;
using System.ComponentModel;
using System.Text;
using NLog.Config;

Expand Down Expand Up @@ -133,6 +134,8 @@ public string Name
/// If not set explicitly then the value of the parent will be used as default.
/// </remarks>
/// <docgen category='Layout Options' order='100' />
[Obsolete("Marked obsolete since forward slash are valid JSON. Marked obsolete with NLog v5.4")]
[EditorBrowsable(EditorBrowsableState.Never)]
public bool EscapeForwardSlash { get => EscapeForwardSlashInternal ?? false; set => EscapeForwardSlashInternal = value; }
internal bool? EscapeForwardSlashInternal { get; private set; }

Expand Down Expand Up @@ -170,7 +173,10 @@ internal bool RenderAppendJsonValue(LogEventInfo logEvent, IJsonConverter jsonCo

if (Encode)
{
Targets.DefaultJsonSerializer.PerformJsonEscapeWhenNeeded(builder, orgLength, EscapeUnicode, EscapeForwardSlash);
#pragma warning disable CS0618 // Type or member is obsolete
var escapeForwardSlash = EscapeForwardSlash;
#pragma warning restore CS0618 // Type or member is obsolete
Targets.DefaultJsonSerializer.PerformJsonEscapeWhenNeeded(builder, orgLength, EscapeUnicode, escapeForwardSlash);
builder.Append('"');
}
}
Expand Down
2 changes: 2 additions & 0 deletions 2 src/NLog/Layouts/JSON/JsonLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ protected override void InitializeLayout()
{
if (!attribute.EscapeForwardSlashInternal.HasValue)
{
#pragma warning disable CS0618 // Type or member is obsolete
attribute.EscapeForwardSlash = _escapeForwardSlashInternal.Value;
#pragma warning restore CS0618 // Type or member is obsolete
}
}
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.