SenseNet / sn-io

Import and export features and tools for the sensenet repository.
GNU General Public License v2.0
0 stars 0 forks source link

SnIO missing log. #41

Closed kavics closed 6 months ago

kavics commented 1 year ago

The logger seems to be registered and configured correctly but it doesn't write anywhere. The logger works well if it is configured in code for example:

.WriteTo.File("logs43/snio-.log", LogEventLevel.Verbose, rollingInterval: RollingInterval.Day)

The working verbose log complete configuration in code:

.ConfigureLogging((hostBuilder, loggingBuilder) =>
{
    loggingBuilder.ClearProviders();
    loggingBuilder.AddSerilog(new LoggerConfiguration()
        .ReadFrom.Configuration(hostBuilder.Configuration)
        .MinimumLevel.Verbose()
        .WriteTo.File("logs43/snio-.log", LogEventLevel.Verbose, rollingInterval: RollingInterval.Day)
        .CreateLogger());
})

Expectation: if the tool is registered as a dotnet tool and executed from the command line (3rd party dev scenario), it should create a local or global log.

tusmester commented 1 year ago

The issue is that the appsettings file is missing. ~We must make sure we include that in the package in a way that it is copied during installation wherever the tool is installed on the dev machine.~

UPDATE: there is this line in the code that sets the path where the app looks for configuration to the current folder:

configurationBuilder.SetBasePath(Directory.GetCurrentDirectory());

This means the developer should have an appsettings.json (or a providerSettings.json) file in that folder in order to load config values. We should consider also loading a config file that reflects the name of the tool, e.g. snio.json.