[3.0.0-rc3] Logging object with circular references breaking
See original GitHub issuev3.0.0-rc3
When logging data with circular data, it does not log and subsequent logs are not logged neither
const customData = {};
customData.myself = customData; // circular data
const logger = winston.createLogger({ transports: [new winston.transports.Console()] });
logger.info('hello'); // shows on console
logger.error({
message: 'testing error',
myCustomData: customData,
}); // doesn't log
logger.info('hello'); // doesn't log
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Logging object with circular reference with Mongo Appender ...
I've blogged some days ago on the possibility to save log4net logs inside a Mongo database, but you should be aware that this...
Read more >Detecting and fixing circular references in JavaScript
Here is MDN's approach to detecting and fixing circular references when using JSON.stringify() on circular objects: ...
Read more >Remove or allow a circular reference - Microsoft Support
The formula =D1+D2+D3 breaks because it lives in cell D3, and it's trying to calculate itself. To fix the problem, you can move...
Read more >Circular Dependencies in Dependency Injection - Medium
A description of how we solved a circular dependency in our dependency injection, and some of the software principles involved.
Read more >code quality - What's wrong with circular references?
Circular object references also make dependency injection impossible, significantly reducing the testability of your system. Objects with a very ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@crussell52 @Nokel81 @danlevan removing built-in, default always on support for logging of circular object references was a conscious performance decision for the default
winston
behavior inwinston@3
.This problem is 100% solvable as a custom format – here’s a quick & dirty one. If you’d like to contribute one to
logform
(likecircular-json
or perhaps a{ circular: true }
option that users must opt-in to) that would be neat.This may be arguable the more important point – I ran into a case where a formatter threw an exception and all subsequent log attempts quietly failed. An edge-case failure in logging a message should not halt all logging 😟
Is that expected behavior?