public void ConfigureServices(IServiceCollection services) { services.AddMvcCore() .AddApiExplorer() .AddJsonFormatters(delegate(JsonSerializerSettings settings) { settings.DateFormatHandling = DateFormatHandling.IsoDateFormat; settings.Error = (sender, args) => { var logger = LoggerFactoryManager.GetLogger <JsonSerializerSettings>(); var objectName = args.CurrentObject?.GetType().FullName ?? "Unknown"; logger.LogWarning($"Failed to deserialize [{objectName}] JSON on input: {args.ErrorContext.Error.Message}"); }; }); // Add the config services.AddSingleton(Program.AppConfig); // Create the actor system services.AddSingleton(_ => { // Simple solution to inject our logger LoggerFactoryManager.Init(_); return(ActorSystem.Create("faresandticketing", HoconLoader.FromFile(Path.Combine(Directory.GetCurrentDirectory(), HoconFileName)))); }); // Add the ES client implementation //services.AddSingleton<IESClient, ESClient>(_ => new ESClient(_.GetRequiredService<ILogger<ESClient>>(), _.GetRequiredService<AppConfig>())); services.AddFareServices(); services.AddSwaggerGen(c => c.SwaggerDoc("v1", new Info { Title = "Quote Validator V1", Version = "v1" })); }
public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext) { IMethodReturn result = getNext()(input, getNext); LoggerFactoryManager.SetFactory <LoggerFactory>(); LoggerFactoryManager.Create.Log(input.MethodBase.Name); return(result); }