Filename includes timezone offset. How to disable?
See original GitHub issueI have faced with issue that the datePattern includes timezone offset. I would like to have the file names in UTC.
I’m using the next settings:
export interface IWinstonFactoryOptions {
prefix?: string;
console?: boolean;
path: string;
maxFiles: number;
}
function loggerFormat(data: TransformableInfo): string {
return `${data.timestamp} [${data.label || ''}] ${data.level}: ${(data.durationMs !== undefined
? `(${data.durationMs}ms) `
: '') + data.message}`;
}
export function createWinstonLogger(opts: IWinstonFactoryOptions): Logger {
const prefix = opts.prefix || 'log_';
const console = opts.console || false;
const logger = createLogger({
exitOnError: false,
level: 'silly',
});
logger.add(
new DailyRotateFile({
format: format.combine(format.timestamp(), format.printf(loggerFormat)),
filename: `${prefix}%DATE%.log`,
datePattern: 'YYYY-MM-DDTHH',
zippedArchive: false,
maxFiles: opts.maxFiles,
dirname: opts.path,
})
);
if (console) {
logger.add(
new transports.Console({
format: format.combine(format.colorize(), format.timestamp(), format.printf(loggerFormat)),
})
);
}
return logger;
}
Especially please look here: datePattern: 'YYYY-MM-DDTHH'
In practice I have the file: app_2019-07-24T22.log
where the first line is: 2019-07-24T19:05:26.185Z [label] ...
.
(I have +03 hours timezone)
Is that an issue or expected behaviour? I haven’t found way to force to use file rotator only UTC for file names.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Timezone offset in filenames without using + symbol? - Reddit
I personally use the "։" symbol (U+A789: MODIFIER LETTER COLON) in file names instead of a colon. It's just a Unicode character that...
Read more >Having trouble setting a time zone offset during file renaming
I've solved it by looping through the folders on the card (100EOS5D, 101EOS5D, 102EOS5D, etc.), changing the filenames during the copy, and then ......
Read more >Remove Time Zone Offset from DateTimeOffset?
My end goal is just to have a date without a time or a time zone offset. I do not want to convert...
Read more >How to remove timezone information from DateTime object in ...
To remove timestamp, tzinfo has to be set None when calling replace() function. First, create a DateTime object with current time using datetime ......
Read more >ZoneOffset (Java Platform SE 8 ) - Oracle Help Center
A time-zone offset from Greenwich/UTC, such as +02:00 . ... To prevent any problems with that range being extended, yet still provide validation,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This feature is being tracked at https://github.com/rogerc/file-stream-rotator/issues/31. Once this is supported by the file-stream-rotator component, I can publish a new version of winston to support the option.
@mattberther That would be great to have this option. I’m using Winston with application which is rotating on raspberry devices, and each has personal timezone and it’s a headache to have files not in UTC. If you can, please, publish new version with ability to use UTC for file names.
Thank you