## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
• Create your own community
##### Activity
• Jan 31 15:14
indexzero commented #1498
• Jan 31 15:13
indexzero commented #1498
• Jan 31 15:04
kbirger commented #1498
• Jan 31 13:01
indexzero commented #1591
• Jan 31 13:01
indexzero closed #1591
• Jan 31 12:59
papandreou commented #1591
• Jan 31 10:41
papandreou commented #1591
• Jan 31 10:40
• Jan 31 09:50
papandreou opened #1591
• Jan 30 23:01
DanielRuf opened #1590
• Jan 30 16:33
ahce edited #1588
• Jan 30 16:32
ahce closed #1587
• Jan 30 16:32
ahce commented #1587
• Jan 30 15:29
ColinMorris83 commented #1577
• Jan 30 15:07
indexzero commented #1577
• Jan 30 14:56
ColinMorris83 commented #1577
• Jan 30 14:33
sapsaldog commented #1501
• Jan 30 14:30
• Jan 30 14:29
sapsaldog commented #1501
• Jan 30 14:28
Poyo
@Poyo-SSB
Unrelated inquiry—
Is it possible to chunk log files when they become too large?
tagyoureit
@tagyoureit
@dabh @indexzero The PR I pushed up had some mangled code. I'm going to pull my PR down for a bit and see if I can rework it. I have some questions and want to do my code most in the spirit of how everything else is already coded. What's the best place to ask those questions/have that conversation? Here? Private thread?
David Hyde
@DABH
Hey @tagyourit ! Sorry I’m pretty swamped with personal stuff till end of next week. But I absolutely want to figure this out and make any helpful changes (it’s about time!). Private thread in Gitter (if that’s possible) is probably best so we can try to have an uninterrupted linear conversation on this :) I’ll be as responsive as I can, though much more responsive after next week - thanks for understanding
I read through your above messages and I think I understand the issues at hand here — but would probably be useful to work through this from the top (copy/paste as needed) so we all have the most context
Also @indexzero what happened to migrating to Slack/discord, the Gitter UI leaves much to be desired, ha...
Bernardo Vieira
@obernardovieira
Hello, Is it possible to log into a file using typescript? I've got fs.existsSync error
David Hyde
@DABH
Yes, winston works with typescript. Does the directory where you want your log file to appear exist?
Bernardo Vieira
@obernardovieira
Bernardo Vieira
@obernardovieira
Hi guys, Can anyone help me please?
Clite Tailor
@clitetailor
Hi everyone, Is there any way to create a child logger from the default logger?
Peter Reid
@ReidWeb

HMM. anyone know why i may be facing this issue

"Cannot find module './combine.js'",

when running in a lambda?

Mohit
Hello, Logger does not log when requests serve with 200 found response codes from server
but it logs for other responses.. i.e, 404 etc..
louis choi
@loolaz
does anyone know how to flush data to the file before closing the current stream?
Is there a way to specify a unique logform Format for each transport? Like use one format for a Console transport and another for File transports? It seems like that would be a pretty basic option, but I can't find it anywhere in the documentation....
So, from the number of stockpiled question without any answers, I guess this Gitter is pretty much dead.
tagyoureit
@tagyoureit
The main guys that run this are really busy... but yes, you can do that. You can pass the formatting to the transport itself and then add this to the logger. (Leave the formatting off of the logger.)
// _transports is an array of transports.
let _transports: any = {
console: new winston.transports.Console( {
level: 'error',
format: winston.format.combine(
winston.format.timestamp({
format: timestampFormat()
}),
winston.format.colorize(),
winston.format.splat(),
winston.format.simple(),
myFormat)
} )

// define the logger
_logger = winston.createLogger( {
level: 'error',
exitOnError: false,
transports: [ _transports.console ]
} )

// later, I add a custom transport with different formatting
_transports.socketTransport = new SocketTransport( {
level: level,
format: winston.format.combine(
winston.format.timestamp({
format: timestampFormat()
}),
winston.format.splat(),
winston.format.simple(),
debugFormat
),
} )
_logger.add( _transports.socketTransport );
@tagyoureit Thank you; your answer helped a lot! :)
Would anybody be able to tell me if it's possible adjust the level of a single transport, at runtime, of a custom logger, without just clearing the whole transport/logger and making a new one? If so, how? I've searched online about this, but all the information I can find is either for an older, <3.0.0 version or just doesn't work, including these issues on GitHub: winstonjs/winston#315 and winstonjs/winston#1167
Specifically, using Logger.transports['console'].level = 'debug' gives me an error: TypeError: Cannot set property 'level' of undefined
I've tried explicitly setting the transport name with the name option but it hasn't helped.
Additionally, replacing transports Winston's internal pipes hash also gives a compilation error: Logger._readableState.pipes['console'].level = 'debug'; TypeError: Cannot set property 'level' of undefined
tagyoureit
@tagyoureit
@Anadian Yes, you can do that. See my example above. I'm able to call _transports[ tport ].level = lvl and set the level. Basically, _transports['console'].level = 'debug' will set the level to debug.
@tagyoureit Logger._transports['console'].level = 'debug'; still gives me
        Logger._transports['console'].level = 'debug';
^

TypeError: Cannot read property 'console' of undefined
tagyoureit
@tagyoureit
If you look at my code, there is no Logger object. I am using _transports as an array to hold the transports and _logger as my logger implementation. Do you have a Logger object? Does it contain an array called _transports?
It took some fiddling but I was able to get it to work similar to @tagyoureit's example; in essence, keeping the actual transports as properties in a separate object and passing references to those properties to Winston's transports array. Then I could just add another property to the resulting custom logger, called real_transports, which points the aforementioned separatetransports object. Works perfectly fine; even if it does feel quite a bit hackish.
tagyoureit
@tagyoureit
You should also be able to access the transport inside the logger itself. Again with my code, I would be able to set the level directly with _logger.transports[0].level . The transports aren't stored via their names in the loggers so if you wanted to access it directly you should check (in a loop, for example) _logger.transports[i].name and it should equal console.
Lyth0
@Lyth0
hey, is someone here working with winston-daily-rotate-file and using the logger in mocha and got this error: Error: Unknown object type "asyncfunction"
Matt Berther
@mattberther
@Lyth0 I maintain this library. If you could provide some additional information on what you're doing to trigger this error, it could help resolve.
Lyth0
@Lyth0

Stack:

Error: Unknown object type "asyncfunction"
at Object._object (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:218:17)
at Object._function (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:319:14)
at Object.dispatch (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:242:21)
at Object.dispatch (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:242:21)
at Object.dispatch (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:242:21)
at Object._function (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:319:14)
at Object.dispatch (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:242:21)
at Object._function (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:319:14)
at Object.dispatch (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:242:21)
at Object.dispatch (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:242:21)
at Object.dispatch (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:242:21)
at Object.dispatch (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:185:30)
at hash (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:128:10)
at objectHash (G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:33:10)
at new DailyRotateFile (G:\Data\Projekte\Voixt\node_modules\winston-daily-rotate-file\daily-rotate-file.js:90:95)
at new PreDefinedDailyRotateFile (G:\Data\Projekte\Voixt\src\logging\transport\PreDefinedDailyRotateFile.ts:39:7)
at new CommandLogger (G:\Data\Projekte\Voixt\src\logging\CommandLogger.ts:17:10)
at Object.get (G:\Data\Projekte\Voixt\node_modules\typescript-ioc\src\typescript-ioc.ts:412:62)
at SingletonScope.resolve (G:\Data\Projekte\Voixt\node_modules\typescript-ioc\src\typescript-ioc.ts:539:33)
at ConfigImpl.getInstance (G:\Data\Projekte\Voixt\node_modules\typescript-ioc\src\typescript-ioc.ts:461:30)
at Function.IoCContainer.get (G:\Data\Projekte\Voixt\node_modules\typescript-ioc\src\typescript-ioc.ts:316:23)
at AddVoiceTextChainCommand.get [as logger] (G:\Data\Projekte\Voixt\node_modules\typescript-ioc\src\typescript-ioc.ts:334:85)
at AddVoiceTextChainCommand.exec (G:\Data\Projekte\Voixt\src\core\VoixtCommand.ts:19:12)

But looks like its some problem with daily-rotate-file and typescript-ioc. But not sure if its ioc or drf now :/ If I remove typescript-ioc and initialize ne logger with new CommandLogger() it works

Lyth0
@Lyth0

@mattberther okay maybe ioc is only a part... I got a similiar problem...

Using TypeORM to create the connection and pass a logger instance (DatabaseLogger without IOC)

export function createDatabaseConnection(): Promise<Connection> {
return getConnectionOptions("develop").then((config) => {
const additionalConfig = {
entities: [BaseEntity, VoiceTextChain, CategoryTextChainListener, GuildSettings],
synchronize: true,
cache: {
type: "database",
duration: 30000,
},
logging: "all",
logger: new DatabaseLogger(),
};

const newConfig = Object.assign(config, additionalConfig);

return createConnection(newConfig);
});
}
Error: Unknown object type "generatorfunction"
at Object._object (node_modules\object-hash\index.js:218:17)
at Object._function (node_modules\object-hash\index.js:319:14)
at Object.dispatch (node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (node_modules\object-hash\index.js:242:21)
at Object.dispatch (node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:260:23
at Array.forEach (<anonymous>)
at Object._array (node_modules\object-hash\index.js:259:20)
at Object._object (node_modules\object-hash\index.js:214:30)
at Object.dispatch (node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:278:16
at Array.map (<anonymous>)
at Object._array (node_modules\object-hash\index.js:274:25)
at Object._map (node_modules\object-hash\index.js:383:19)
at Object._object (node_modules\object-hash\index.js:214:30)
at Object.dispatch (node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:260:23
at Array.forEach (<anonymous>)
at Object._array (node_modules\object-hash\index.js:259:20)
at Object._object (node_modules\object-hash\index.js:214:30)
at Object.dispatch (node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:260:23
at Array.forEach (<anonymous>)
at Object._array (node_modules\object-hash\index.js:259:20)
at Object._map (node_modules\object-hash\index.js:383:19)
at Object._object (node_modules\object-hash\index.js:214:30)
at Object.dispatch (node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (node_modules\object-hash\index.js:242:21)
at Object.dispatch (node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (node_modules\object-hash\index.js:242:21)
at Object.dispatch (node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (node_modules\object-hash\index.js:242:21)
at Object._function (node_modules\object-hash\index.js:319:14)
at Object.dispatch (node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (node_modules\object-hash\index.js:242:21)
at Object._function (node_modules\object-hash\index.js:319:14)
at Object.dispatch (node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (node_modules\object-hash\index.js:242:21)
at Object.dispatch (node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (node_modules\object-hash\index.js:242:21)
at Object.dispatch (node_modules\object-hash\index.js:185:30)
at G:\Data\Projekte\Voixt\node_modules\object-hash\index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (node_modules\object-hash\index.js:242:21)
at Object.dispatch (node_modules\object-hash\index.js:185:30)
at hash (node_modules\object-hash\index.js:128:10)
at objectHash (node_modules\object-hash\index.js:33:10)
at new DailyRotateFile (node_modules\winston-daily-rotate-file\daily-rotate-file.js:90:95)
at new PreDefinedDailyRotateFile (src\logging\transport\PreDefinedDailyRotateFile.ts:39:7)
at new DatabaseLogger (src\logging\DatabaseLogger.ts
before(async () => {
await createDatabaseConnection();
i18n.configure({
....
});

....
});
Lyth0
@Lyth0
okay... If I remove the format argument from the logger it works... But I do not really understand why
Matt Berther
@mattberther
@Lyth0 Not really sure either, as I don't have any experience with typescript-ioc. Given that it works without this in place, I imagine it has something to do with how that library is managing things. I'd recommend filing an issue with them.
cloverb
@cloverb
Hey, can the maintainers please address these issues in winston-syslog: winstonjs/winston-syslog#104 & winstonjs/winston-syslog#103
cloverb
@cloverb
@mattberther
Matt Berther
@mattberther
@cloverb I am not a maintainer on that project. You're probably looking for @indexzero or https://github.com/santigimeno
cloverb
@cloverb
@mattberther thank you
cloverb
@cloverb
@indexzero @DABH What would it take to get this looked at? There is a working PR open to fix it that is very small and shouldn't be to time-consuming to review.
David Hyde
@DABH
@cloverb I just reviewed those
cloverb
@cloverb
Thank you so much @DABH !
iamkenos
@iamkenos
hi folks, im migrating to winston 3
i noticed that doing logger.verbose("my message and ", foo); now prints my message and while it used to print my message and foo value in winston 2
how can i configure my logger to print the args after the message?
tagyoureit
@tagyoureit
I have a (long) outstanding PR (winstonjs/logform#85) and Issue (https://github.com/winstonjs/winston/issues/1408) for this. Unfortunately it hasn't been merged yet. Best thing to do is add the token placeholder or switch to using ES6 template literals.
cloverb
@cloverb
@DABH thank you for merging that PR! I was just wondering when you might cut the v2.2.0 release with it?
bsmerbeckuri
@bsmerbeckuri

Hey guys...I have a question which I imagine is heard a lot.
I was trying to set up winston so that I could create different mailing lists for notifications. So one list would be user interactions, one would be system events, one would be security events, etc. However, I've gotten hung up on the functionality of winston where a log of a lower priority (higher number) contains the entries of the higher priority. From what I can see, the only way to solve this would be to have a logger for each of these different style of events.

If I were to do that, however, I wouldn't be able to get the benefits from the debug(info) level. So....i don't know I'm just kind of conflicted as to how to accomplish this implementation

The whole idea was to use the logger with transports per level so that i'd have a .csv file corresponding with each level to email to it's respective mailing list.
bsmerbeckuri
@bsmerbeckuri
Solved it, for anyone looking it's the format syntax
function filterOnly(level) {
return format(function (info) {
if (info[LEVEL] === level) {
return info;
}
})();
}

const logger = createLogger({
format: zformat,
transports: [
// only 'info' level
new transprts.File({
level: 'info',
format: filterOnly('info'),
filename: 'logs/access.log',
}),
// any level below 'verbose'
new transports.File({
level: 'verbose',
format: filterOnly('verbose'),
filename: 'logs/combined.log',
})
]
});
David Hyde
@DABH
@cloverb I (finally) published v2.2.0 for winston-syslog on npm. Let me know if you have any issues!
@bsmerbeckuri yeah, there's a similar solution at https://stackoverflow.com/a/56918394/4451284 . Seems reasonable to me