Пример #1
0
        private static void ConfigureLogging(HostBuilderContext context, ILoggingBuilder logging)
        {
            var path = ProcessUtility.GetExecutionPath();
            var file = Path.Join(path, Constants.LogFileName);

            logging.ClearProviders();

            logging.AddFile(file, LogLevel.Information, new Dictionary <string, LogLevel>
            {
                { "System", LogLevel.None },
                { "Microsoft", LogLevel.None }
            });
        }
Пример #2
0
        private static Settings GetSettings()
        {
            var path = ProcessUtility.GetExecutionPath();
            var file = Path.Join(path, Constants.SettingsFileName);

            if (File.Exists(file))
            {
                return(JsonSerializer.Deserialize <Settings>(File.ReadAllText(file)));
            }

            var settings = new Settings();
            var options  = new JsonSerializerOptions {
                WriteIndented = true
            };

            File.WriteAllText(file, JsonSerializer.Serialize(settings, options));

            return(settings);
        }