Closed GGY-CM closed 3 years ago
You can achieve this pretty easy by subclassing FileLoggerProcessor and overriding the GetCounter virtual method.
I put together a sample console app for you to demonstrate how to do this.
However, I'll consider introducing some hook to control this from the settings. A CounterFormatter callback or something.
Thank you very much.
Version 3.2.0 introduces the previously mentioned hook mechanism. Now this is possible through configuration, without subclassing anything:
builder.AddFile(o =>
{
o.RootPath = AppContext.BaseDirectory;
o.PathPlaceholderResolver = (placeholderName, inlineFormat, context) =>
placeholderName == "counter" ?
(context.Counter + 1).ToString(inlineFormat ?? context.CounterFormat, CultureInfo.InvariantCulture) :
null;
});
Hi,
Can you add a setting to allow set the start value of the counter? or set its start value to 1 instead of 0?
Thanks,