question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

question: why are logs duplicated across/up levels?

See original GitHub issue

Pretty new to winston. Read through the docs, a little confused about the following:

Not sure if its just my config or if this is the expected behavior but when I log something using logger.error() it’s logged to my info, debug and error log. logger.info() is logged to both info and debug. logger.debug() is logged to debug.

my config:

var logger = new (winston.Logger)({
    transports: [
        new (winston.transports.Console)(),
        new (winston.transports.File)({
            name: 'error-file',
            filename: 'jj-error.log',
            level: 'error'
        }),
        new (winston.transports.File)({
            name: 'info-file',
            filename: 'jj-info.log',
            level: 'info'
        }),
        new (winston.transports.File)({
            name: 'debug-file',
            filename: 'jj-debug.log',
            level: 'debug'
        })
    ]
});

for example:

logger.error('an error'); 
logger.info('some info'); 
logger.debug('useful info'); 

yields the following: jj-error.log:

{"level":"error","message":"an error"}

jj-info.log:

{"level":"error","message":"an error"}
{"level":"info","message":"some info"}

jj-debug.log:

{"level":"error","message":"an error"}
{"level":"info","message":"some info"}
{"level":"info","message":"some info"}

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
countless-integerscommented, Mar 3, 2016

I think this is how it was intended to work – when you increase log verbosity (e.g. to debug) you get more messages. If you want to around this you could create custom logger for different message types you want to log – bit excessive, but it does the job.

1reaction
sholladaycommented, May 6, 2016

The appropriate configuration to customize this is levels, on the Logger instance.

const logger = new winston.Logger({
    levels : {
        error   : 0,
        warn    : 1,
        info    : 2,
        verbose : 3,
        debug   : 4,
        silly   : 5
    }
});

As specified in RFC 5424, the lower the number, the more important the message.

So everyone gets informed of an error. But hardly anyone needs to know about silly things.

Using the configuration, you can reverse this order or do whatever you want, but you should follow the standard if you can.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why getting duplicated log info when using django?
Both the handlers console (which handles logs of level >= INFO) and jenkins (which handles logs of level >= DEBUG) are handling your...
Read more >
Preventing Duplicate Logs - New Relic Explorers Hub
Trimming duplicate logs doesn't seem like it should be based on a query, but rather an inbuilt feature of the Logs API/SDK. e.g....
Read more >
duplicate log - Google Groups
I was wondering if anyone can tell me why my experiment is logging a duplicate of ... array so that one level stays...
Read more >
At which level do duplicate rules work?
Yes, Duplicate Rules will block concurrent duplicates. The use of Duplicate Rules can cause some database contention, but prevents ...
Read more >
Duplicate Log Entries In Windows Event Logs - TechNet
Usually we get multiple events. For example, if you open a document you are also viewing it so it will give you two...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found