public static void CheckForDebugHook() { #if DEBUG var debugBreak = ConfigUtils.ReadSettingFromAppConfigIfPresent("DebugBreak"); if (bool.TryParse(debugBreak, out var waitForDebugger) && waitForDebugger) { while (!Debugger.IsAttached) { Task.Delay(TimeSpan.FromSeconds(2)).Wait(); Log.Debug("Waiting for debugger to attach"); } Debugger.Break(); Log.Debug("Debugger attached"); } #endif }
public static void ConfigureLogging() { var logConfig = new LoggerConfiguration().MinimumLevel.Debug().WriteTo.Console(); var loggingDirectory = ConfigUtils.ReadSettingFromAppConfigIfPresent("LoggingDirectory"); if (loggingDirectory != null) { if (!Path.IsPathRooted(loggingDirectory)) { loggingDirectory = Path.Combine(Assembly.GetEntryAssembly().Location, loggingDirectory); } logConfig.WriteTo.File(Path.Combine(loggingDirectory, "SampleA2aService-{Date}.log"), LogEventLevel.Debug); } Log.Logger = logConfig.CreateLogger(); }