uship / uship.logging Goto Github PK
View Code? Open in Web Editor NEWFluent log4net logging library
License: MIT License
Fluent log4net logging library
License: MIT License
To reproduce with a fresh Elastic Search index:
var logger = Logger.GetInstance();
logger.WriteMinimalDataLog("invalid json data");
const string json = "{\"property\":\"value\"}";
logger.WriteMinimalDataLog(json, Severity.Info);
The first message makes it into the index. The type of "properties.data" is now a string because of the JSON deserialization fallback in MinimalLogDataBuilder.cs. When the second message is sent, it is silently dropped since it does not match the type (since it converted into an object since it is valid JSON).
Proposed solution:
Wrap all invalid JSON in a object as shown below
const string json = "{\"message\":\"invalid json data\"}";
Doing something like...
_logger.Message('mah message').Data('RequestBody', requestBody).Info().Write();
Causes the logger to log an INFO message with "Error Building Log Properties".
No exception is thrown/bubbled up, so the programmer is pretty much left at a loss / assumes it never may be logged.
Possible fixes/Proposals:
Just allowing users to override these required properties/already logged properties could be bad (per the advice of @digitalpacman ) due to possible differences in data types/etc, that might cause true silent failure in the logger.
we could change the Error Building Log Properties
to ERROR, but apparently this bugs people (personally, I think it should. Let's fix our logs instead of just ignoring them...)
@digitalpacman proposes the .Data() method utilize a prefix on custom fields.
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.