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.

Shared Transports

See original GitHub issue

I am having trouble setting up shared transports.

I am using this method to add the shared transports:

winston.loggers.add('some-category', {
    transports: [
      // Setup your shared transports here
    ]
});

Basically, I have two types of loggers one “debugLogger”, and then a large number of “specificDebugLoggers”. I want the specific debug loggers to each get their own file, but I also want them to log output to the main debug file.

However, when I try and share the transports, I get this error:

Error: Transport already attached: file

Here is what I am doing:

debugFileTransport = {
    filename: '/var/log/mycoolapp/debug.log',
};

// Here is how the main debug log is created.
winston.loggers.add('debugLogger', {
  transports: [
    new winston.transports.File(debugFileTransport)  // Here is the shared transport
  ]
});

// And here is how the specific debug logs get created.
createLogger = function(name, filepath) {
  winston.loggers.add(name, {
    transports: [
      new winston.transports.File(debugFileTransport), // Here is the shared transport
      new winston.transports.File({
        filename: filepath,
      })
    ]
  });
  return winston.loggers.get(name);
};

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Comments:25 (8 by maintainers)

github_iconTop GitHub Comments

9reactions
yhparkcommented, Nov 15, 2013

@ash211 @gdbtek or anyone who see this thread, You should set name field in the option. It’s being used to detect duplicate transports.

new winston.transports.File({ filename: './logs/error.log', name: 'file.error', level: 'error' }),
new winston.transports.File({ filename: './logs/info.log', name: 'file.info', level: 'info' }),
new winston.transports.File({ filename: './logs/debug.log', name: 'file.debug', level: 'debug' })
3reactions
sudoseancommented, Jun 12, 2017

Hi, I have followed along with the docs and these past issues. I no longer receive the original issues but I am only getting output to one file :

const winston = require(`winston`);

winston.level = 'debug';

winston.configure({
    transports: [
        new (winston.transports.File)({ filename: 'logs/info.log', name: 'file.info', level: 'info'}),
        new (winston.transports.File)({ filename: 'logs/warn.log', name: 'file.error', level: 'error'})
    ]
});


module.exports = winston;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Shared transport - Wikipedia
Shared transport or shared mobility is a transportation system where travelers share a vehicle either simultaneously as a group (e.g. ride-sharing) or over ......
Read more >
What Is Shared Mobility? - Shared-Use Mobility Center
We broadly define shared mobility as transportation services and resources that are shared among users, either concurrently or one after another.
Read more >
What does shared transport mean? - Definitions.net
Shared transport is a term for describing a demand-driven vehicle-sharing arrangement, in which travelers share a vehicle either simultaneously as a group ...
Read more >
Integration of shared transport at a public transport stop: mode ...
Two studies regarding bicycle sharing in the Netherlands showed that shared bicycles are often used as a substitute for the bus, tram, metro,...
Read more >
Shared Transport Definition: 113 Samples | Law Insider
Shared Transport is defined as local interoffice transmission facilities shared by more than one Carrier, including Qwest, between End Office Switches, ...
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