@@ -29,19 +29,21 @@ namespace Gnoss.BackgroundTask.CacheRefresh
2929{
3030 public class Program
3131 {
32+ private static Serilog . ILogger _startupLogger ;
3233 public static void Main ( string [ ] args )
3334 {
34- LoggingService . ConfigurarBasicStartupSerilog ( ) . CreateBootstrapLogger ( ) ;
35+ _startupLogger = LoggingService . ConfigurarBasicStartupSerilog ( ) . CreateBootstrapLogger ( ) . ForContext < Program > ( ) ;
3536 try
3637 {
3738 CreateHostBuilder ( args ) . Build ( ) . Run ( ) ;
3839 }
3940 catch ( Exception ex )
4041 {
41- Log . Fatal ( ex , "Error fatal durante el arranque" ) ;
42+ _startupLogger . Fatal ( ex , "Error fatal durante el arranque" ) ;
4243 }
4344 finally
4445 {
46+ ( _startupLogger as IDisposable ) ? . Dispose ( ) ;
4547 Log . CloseAndFlush ( ) ; // asegura que se escriben todos los logs pendientes
4648 }
4749 }
@@ -52,12 +54,14 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
5254 . UseSystemd ( ) //Linux
5355 . ConfigureAppConfiguration ( ( hostContext , config ) =>
5456 {
55- config . AddJsonFile ( "appsettings.json" , optional : false , reloadOnChange : true ) ;
56- config . AddJsonFile ( $ "appsettings.{ hostContext . HostingEnvironment . EnvironmentName } .json", optional : true , reloadOnChange : true ) ;
57+ LoggingService . ConfigurarSeguimientoFicheros ( hostContext , config , _startupLogger ) ;
5758 } )
5859 . UseSerilog ( ( context , services , configuration ) => LoggingService . ConfigurarSerilog ( context . Configuration , services , configuration ) )
5960 . ConfigureServices ( ( hostContext , services ) =>
6061 {
62+ LoggingService . SuscribirCambios ( hostContext , _startupLogger ) ;
63+ _startupLogger . Information ( "Suscripción a cambios de configuración registrada" ) ;
64+
6165 IConfiguration configuration = hostContext . Configuration ;
6266
6367 AppContext . SetSwitch ( "Npgsql.EnableLegacyTimestampBehavior" , true ) ;
0 commit comments