Cysharp / ZLogger

Zero Allocation Text/Structured Logger for .NET with StringInterpolation and Source Generator, built on top of a Microsoft.Extensions.Logging.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to format log entry timestamp?

robertmircea opened this issue · comments

Is it possible to change the log's timestamp format for text logger?
Currently I am using:

var prefixFormat = ZString.PrepareUtf8<string, DateTime>("{0} [{1}] ");
options.PrefixFormatter = (writer, info) => prefixFormat.FormatTo(ref writer, ConvertLoggingLevel(info.LogLevel), info.Timestamp.DateTime.ToLocalTime());

and obtain the following output:

DBUG [11/15/2020 01:22:30] Running ..........

but I would like a different date format like dd-MM-YYYY HH:mm:ss.fff