8000 Marked NLogViewerTarget and IncludeNLogData as obsolete by snakefoot · Pull Request #5694 · NLog/NLog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Marked NLogViewerTarget and IncludeNLogData as obsolete #5694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 1, 2025
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: 8 additions & 0 deletions src/NLog/LayoutRenderers/Log4JXmlEventLayoutRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ protected override void InitializeLayoutRenderer()
/// Gets or sets a value indicating whether to include NLog-specific extensions to log4j schema.
/// </summary>
/// <docgen category='Layout Options' order='10' />
[Obsolete("Non-Standard Log4j-xml-output. Instead use Log4JXmlEventLayout.Parameters. Marked obsolete with NLog v5.4")]
[EditorBrowsable(EditorBrowsableState.Never)]
public bool IncludeNLogData { get; set; }

/// <summary>
Expand Down Expand Up @@ -289,7 +291,9 @@ protected override void Append(StringBuilder builder, LogEventInfo logEvent)
{
xtw.WriteStartElement("log4j", "event", dummyNamespace);
bool includeNLogCallsite = (IncludeCallSite || IncludeSourceInfo) && logEvent.CallSiteInformation != null;
#pragma warning disable CS0618 // Type or member is obsolete
if (includeNLogCallsite && IncludeNLogData)
#pragma warning restore CS0618 // Type or member is obsolete
{
xtw.WriteAttributeString("xmlns", "nlog", null, dummyNLogNamespace);
}
Expand Down Expand Up @@ -344,7 +348,9 @@ protected override void Append(StringBuilder builder, LogEventInfo logEvent)

// get rid of 'nlog' and 'log4j' namespace declarations
sb.Replace(dummyNamespaceRemover, string.Empty);
#pragma warning disable CS0618 // Type or member is obsolete
if (includeNLogCallsite && IncludeNLogData)
#pragma warning restore CS0618 // Type or member is obsolete
{
sb.Replace(dummyNLogNamespaceRemover, string.Empty);
}
Expand Down Expand Up @@ -426,6 +432,7 @@ private void AppendCallSite(LogEventInfo logEvent, XmlWriter xtw)

xtw.WriteEndElement();

#pragma warning disable CS0618 // Type or member is obsolete
if (IncludeNLogData)
{
xtw.WriteElementSafeString("nlog", "eventSequenceNumber", dummyNLogNamespace, logEvent.SequenceID.ToString(CultureInfo.InvariantCulture));
Expand All @@ -441,6 +448,7 @@ private void AppendCallSite(LogEventInfo logEvent, XmlWriter xtw)
AppendDataProperties("nlog", dummyNLogNamespace, xtw, logEvent);
xtw.WriteEndElement();
}
#pragma warning restore CS0618 // Type or member is obsolete
}

private static void AppendDataProperties(string prefix, string propertiesNamespace, XmlWriter xtw, LogEventInfo logEvent)
Expand Down
4 changes: 4 additions & 0 deletions src/NLog/Targets/ChainsawTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,18 @@ namespace NLog.Targets
/// <code lang="C#" source="examples/targets/Configuration API/Chainsaw/Simple/Example.cs" />
/// </example>
[Target("Chainsaw")]
#pragma warning disable CS0618 // Type or member is obsolete
public class ChainsawTarget : NLogViewerTarget
#pragma warning restore CS0618 // Type or member is obsolete
{
/// <summary>
/// Initializes a new instance of the <see cref="ChainsawTarget" /> class.
/// </summary>
public ChainsawTarget()
{
#pragma warning disable CS0618 // Type or member is obsolete
IncludeNLogData = false;
#pragma warning restore CS0618 // Type or member is obsolete
IncludeEventProperties = true;
}

Expand Down
2 changes: 2 additions & 0 deletions src/NLog/Targets/NLogViewerTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ namespace NLog.Targets
/// <code lang="C#" source="examples/targets/Configuration API/NLogViewer/Simple/Example.cs" />
/// </example>
[Target("NLogViewer")]
[Obsolete("Non-Standard Log4j-xml-output. Instead use ChainsawTarget. Marked obsolete with NLog v5.4")]
public class NLogViewerTarget : NetworkTarget, IIncludeContext
{
private readonly Log4JXmlEventLayout _log4JLayout = new Log4JXmlEventLayout();
Expand Down Expand Up @@ -91,6 +92,7 @@ public NLogViewerTarget(string name) : this()
/// Gets or sets a value indicating whether to include NLog-specific extensions to log4j schema.
/// </summary>
/// <docgen category='Layout Options' order='10' />
[Obsolete("Non-Standard Log4j-xml-output. Instead use Log4JXmlEventLayout.Parameters. Marked obsolete with NLog v5.4")]
public bool IncludeNLogData
{
get => Renderer.IncludeNLogData;
Expand Down
2 changes: 2 additions & 0 deletions tests/NLog.UnitTests/Targets/NetworkTargetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,9 @@ public void Bug3990StackOverflowWhenUsingNLogViewerTarget()
</rules>
</nlog>");

#pragma warning disable CS0618 // Type or member is obsolete
var target = config.LoggingRules[0].Targets[0] as NLogViewerTarget;
#pragma warning restore CS0618 // Type or member is obsolete
Assert.NotNull(target);
}

Expand Down
0