Closed GGY-CM closed 4 years ago
The sample I mentioned in your other issue shows a possible solution to this.
However, application name is static (I mean it doesn't change during a single run), so you can get along even without subclassing:
builder.AddConfiguration(configuration.GetSection("Logging"));
builder.AddFile(o =>
{
/* ... */
var appName = Assembly.GetEntryAssembly().GetName().Name;
foreach (var file in o.Files)
file.Path = file.Path.Replace("<appname>", appName);
});
That is, there are already at least two easy ways to achieve this behavior, therefore I don't think it's worth supporting this out-of-the-box.
Version 3.2.0 introduces a setting which properly handles this without the need of subclassing:
builder.AddFile(o =>
{
o.RootPath = AppContext.BaseDirectory;
var appName = Assembly.GetEntryAssembly().GetName().Name;
o.PathPlaceholderResolver = (placeholderName, _, __) => placeholderName == "appname" ? appName : null;
});
Maybe add a new variable like in the Path, and replace it to current application name in code?
Thanks,