Giter Club home page Giter Club logo

logtail-dotnet's People

Contributors

adikus avatar curusarn avatar gyfis avatar jendatovarys avatar petrheinz avatar shobhitvaish avatar simonrozsival avatar snakefoot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

logtail-dotnet's Issues

Improve JsonSerializerSettings to protect against out-of-memory

Configure ReferenceLoopHandling.Ignore

        private readonly JsonSerializerSettings settings = new JsonSerializerSettings {
            ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
            ContractResolver = new DefaultContractResolver {
                NamingStrategy = new CamelCaseNamingStrategy()
            }
        };

Protect against serialization of the entire world. Ex. Microsoft Extension Logging might log properties of these types:

            settings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
            settings.Converters.Add(new JsonToStringConverter(typeof(System.Reflection.MemberInfo)));
            settings.Converters.Add(new JsonToStringConverter(typeof(System.Reflection.Assembly)));
            settings.Converters.Add(new JsonToStringConverter(typeof(System.Reflection.Module)));
            settings.Error = (sender, args) =>
            {
                args.ErrorContext.Handled = true;   // Ignore Properties that throws Exceptions
            };

With help from custom Json-Converter:

    /// <summary>
    /// JSON converter that just calls ToString on the target value (when non-null).
    /// This is configured as the converter for types that will otherwise spew a lot of irrelevant JSON
    /// into logs.
    /// </summary>
    internal sealed class ToStringJsonConverter : JsonConverter
    {
        private readonly System.Type _type;

        /// <inheritdoc />
        public override bool CanRead => false;

        public ToStringJsonConverter(System.Type type) =>
            _type = type;

        /// <inheritdoc />
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            if (value is null)
            {
                writer.WriteNull();
            }
            else
            {
                writer.WriteValue(value.ToString());
            }
        }

        /// <inheritdoc />
        public override object ReadJson(JsonReader reader, System.Type objectType, object existingValue, JsonSerializer serializer) =>
            throw new NotSupportedException("Only serialization is supported");

        /// <inheritdoc />
        public override bool CanConvert(System.Type objectType) =>
            _type.IsAssignableFrom(objectType);
    }

Fails to load with NLog 5.0.0

Upgrading package NLog.Extensions.Logging from 1.7.4 to the next available 5.0.0 I get the message:

Could not load type 'NLog.Internal.IUsesStackTrace' from assembly 'NLog, Version=5.0.0.0 (...)

To fix I update the ref in logtail-dotnet :
<PackageReference Include="NLog" Version="5.0.0" />
and pack to Logtail.0.2.2.nupkg

Serilog

Is there a way to use logtail as a serilog sink?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.