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

String fromatter #283

Conversation

TooLazyToMakeAName
Copy link

What issue does this PR address?
Implements formatter that avoids the common issue type conflicts in Elasticsearch when different log statements use the same property name differently.

Does this PR introduce a breaking change?
No. All changes are backward compatible.

Please check if the PR fulfills these requirements

  • The commit follows our guidelines
  • Unit Tests for the changes have been added (for bug fixes / features)

Other information:
This addresses #282.

bool formatStackTraceAsArray = false)
: base(omitEnclosingObject, closingDelimiter, renderMessage, formatProvider, serializer, inlineFields, true, formatStackTraceAsArray)
bool formatStackTraceAsArray = false,
bool renderMessageTemplate = true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change; introducing a new (even optional) parameter. Why do you want to change this?

using Serilog.Events;
using Serilog.Formatting.Elasticsearch;

namespace Host
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change the namespace?

/// Note that using this formatter comes at the cost that the exception tree
/// with inner exceptions can grow deep.
/// </summary>
public class ElasticsearchStringifyFormatter : ExceptionAsObjectJsonFormatter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The power of ES is that it can understand the different types. Although I understand what you want here, it reduces functionality in order to fix another issue. A formatter that prefixes the type I can see living in this repository, this class is a small addition for specific use cases. Can it not exist only in your project (or a separate nuget package)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know this was possible and would've loved if it was a part of the original package! Very cool, and solves my issue as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know this was possible and would've loved if it was a part of the original package! Very cool, and solves my issue as well.

Are you then okay with closing this PR and use it directly from your code only?

namespace Host
{
/// <summary>
/// A JSON formatter which ensures no type conflicts arieses in Elasticsearch by casting everything to strings.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo. arieses -> arises.

@mivano
Copy link
Contributor

mivano commented Dec 16, 2019

Closing for now as it can be used from outside the package.

@mivano mivano closed this Dec 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants