logtail / logtail-dotnet Goto Github PK
View Code? Open in Web Editor NEWBetter Stack .NET client
Home Page: https://betterstack.com/logs
License: Other
Better Stack .NET client
Home Page: https://betterstack.com/logs
License: Other
Have any questions? Please explore the Logtail documentation or contact our support.
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);
}
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
Is there a way to use logtail as a serilog sink?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.