How to enable timestamps in file transports.
This is definition of FileTransportOptions
interface FileTransportOptions extends Transport.TransportStreamOptions {
filename?: string;
dirname?: string;
options?: object;
maxsize?: number;
stream?: NodeJS.WritableStream;
rotationFormat?: Function;
zippedArchive?: boolean;
maxFiles?: number;
eol?: string;
tailable?: boolean;
}
I found only this way:
new winston.transports.File({
filename: './logs/ttracker.log',
timestamp: tsFormat, // makes timestamp 'pretty'
json: false // makes log format just like console output
})
No timestamp option available in winston 3 looks like it for 2nd version.
Actually pretty hard to do for such essential thing, in most logging frameworks timestamps works from the box.
Howdy – most options like timestamp and json became formatters in winston@3. A timestamp format is included out of the box in winston.format.timestamp – there is a detailed example in examples/ that shows you how to do use it.
We definitely need help in building out the documentation for built-in formats. If you are interested in becoming a first-time contributor this issue would be a great place to start: https://github.com/winstonjs/logform/issues/9
How do you add a custom format that is not based on that library?
I still prefer to use moment not fecha
Most helpful comment
Howdy – most options like
timestampandjsonbecame formatters inwinston@3. A timestamp format is included out of the box inwinston.format.timestamp– there is a detailed example inexamples/that shows you how to do use it.We definitely need help in building out the documentation for built-in formats. If you are interested in becoming a first-time contributor this issue would be a great place to start: https://github.com/winstonjs/logform/issues/9