winston-papertrail icon indicating copy to clipboard operation
winston-papertrail copied to clipboard

JSON being appended to the end of the log

Open shortcircuit3 opened this issue 6 years ago • 9 comments

image

How do I get rid of the extra log object?

shortcircuit3 avatar Dec 20 '18 20:12 shortcircuit3

Bump.... great library btw... would love to know how to fix this as well?

andrewryan1906 avatar Jan 16 '19 13:01 andrewryan1906

This is due to the changes in Winston v3. The new version in the works in the v2 branch by @ffxsam resolves it.

ZacharyDraper avatar Jan 20 '19 22:01 ZacharyDraper

Still exists. Same problem over here. passing inlineMeta: true makes it a bit more readable, but it still sucks

thebarty avatar Oct 01 '19 14:10 thebarty

I've made few changes on my side, to fix that issue:

in function Papertrail.prototype.log
-    if (meta) {
+    if (meta && false) {

This way, the meta information are not appended to the log. It's quite an ugly fix, but the winston v3 change left no other option :( If anyone has a better idea, i'll be delighted to give up that ugly hack

oto-ledger avatar Jan 12 '20 19:01 oto-ledger

any update on this

nomandstrct avatar Aug 07 '24 16:08 nomandstrct

Winston v3 includes pretty thorough built-in syslog support. Try using these instructions to switch to one of the new transports (either Syslog or Http).

markdascher avatar Aug 07 '24 16:08 markdascher

@markdascher you are doing the greatest job. But is there any way we can just remove this meta from logging

nomandstrct avatar Aug 08 '24 09:08 nomandstrct

Not that I'm aware of. Winston v3 broke backward compatibility due to this bug, which doesn't seem like it'll ever be fixed: https://github.com/winstonjs/winston-transport/issues/27

That's why we've started recommending the v3 transports mentioned above, when using Winston v3 with Papertrail.

markdascher avatar Aug 08 '24 16:08 markdascher

worst work around

new Papertrail({
            ...configService.get('papertrail'),
            inlineMeta: true,
            logFormat(level, message) {
              let cleanMessage = message.replace(/\s*{\s*context:.*[^']/g, '');
              cleanMessage = cleanMessage.replace(/\s*{\s*message:.*[^']/g, '');

              return cleanMessage.trim();
            },
          }),

nomandstrct avatar Aug 09 '24 13:08 nomandstrct