flatiron/winston — Issue #101: Shared Transports
Author: bluepines
Created: 2012-02-16 22:17:47+00:00
State: open

I am having trouble setting up shared transports.

I am using this method to add the shared transports:

```javascript
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:

```javascript
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);
};
```