Notify: temp log
This commit is contained in:
parent
1c25d16fc2
commit
794486f335
@ -11,6 +11,7 @@ using Autofac.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace ASC.Common.DependencyInjection
|
||||
{
|
||||
@ -26,12 +27,18 @@ namespace ASC.Common.DependencyInjection
|
||||
|
||||
public static class AutofacExtension
|
||||
{
|
||||
public static IContainer AddAutofac(this IServiceCollection services, IConfiguration configuration, string currentDir, bool loadproducts = true, bool loadconsumers = true, params string[] intern)
|
||||
public static IContainer AddAutofac(this IServiceCollection services, IConfiguration configuration, ILogger logger, string currentDir, bool loadproducts = true, bool loadconsumers = true, params string[] intern)
|
||||
{
|
||||
var folder = configuration["core:products:folder"];
|
||||
var subfolder = configuration["core:products:subfolder"];
|
||||
string productsDir;
|
||||
|
||||
if (logger != null)
|
||||
{
|
||||
logger.LogInformation($"{folder}");
|
||||
logger.LogInformation($"{subfolder}");
|
||||
}
|
||||
|
||||
if (!Path.IsPathRooted(folder))
|
||||
{
|
||||
if (currentDir.EndsWith(Path.Combine(Path.GetFileName(folder), Assembly.GetCallingAssembly().GetName().Name, subfolder)))
|
||||
@ -48,6 +55,11 @@ namespace ASC.Common.DependencyInjection
|
||||
productsDir = folder;
|
||||
}
|
||||
|
||||
if (logger != null)
|
||||
{
|
||||
logger.LogInformation($"{productsDir}");
|
||||
}
|
||||
|
||||
var builder = new ContainerBuilder();
|
||||
var modules = new List<(bool, string)>
|
||||
{
|
||||
@ -130,11 +142,22 @@ namespace ASC.Common.DependencyInjection
|
||||
var dll = type.Substring(type.IndexOf(",") + 1).Trim();
|
||||
var path = GetFullPath(dll);
|
||||
|
||||
if (logger != null)
|
||||
{
|
||||
logger.LogInformation($"LoadAssembly {path}");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
AssemblyLoadContext.Default.Resolving += (c, n) =>
|
||||
{
|
||||
var path = GetFullPath(n.Name);
|
||||
|
||||
if (logger != null)
|
||||
{
|
||||
logger.LogInformation($"Resolve {path}");
|
||||
}
|
||||
|
||||
return path != null ?
|
||||
c.LoadFromAssemblyPath(Path.Combine(Path.GetDirectoryName(path), $"{n.Name}.dll")) :
|
||||
null;
|
||||
|
@ -78,7 +78,7 @@ namespace ASC.ApiSystem
|
||||
.AddSettingsController()
|
||||
.AddTariffController();
|
||||
|
||||
services.AddAutofac(Configuration, HostEnvironment.ContentRootPath, false);
|
||||
services.AddAutofac(Configuration, null, HostEnvironment.ContentRootPath, false);
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
|
@ -12,6 +12,7 @@ using ASC.Notify.Config;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace ASC.Notify
|
||||
@ -20,6 +21,18 @@ namespace ASC.Notify
|
||||
{
|
||||
public static async Task Main(string[] args)
|
||||
{
|
||||
var loggerFactory = LoggerFactory.Create(builder =>
|
||||
{
|
||||
builder
|
||||
.AddFilter("Microsoft", LogLevel.Warning)
|
||||
.AddFilter("System", LogLevel.Warning)
|
||||
.AddFilter("LoggingConsoleApp.Program", LogLevel.Debug)
|
||||
.AddConsole()
|
||||
.AddEventLog();
|
||||
});
|
||||
ILogger logger = loggerFactory.CreateLogger<Program>();
|
||||
logger.LogInformation("Example log message");
|
||||
|
||||
var host = Host.CreateDefaultBuilder(args)
|
||||
.ConfigureAppConfiguration((hostContext, config) =>
|
||||
{
|
||||
@ -66,7 +79,7 @@ namespace ASC.Notify
|
||||
.AddSmtpSenderService()
|
||||
.AddAWSSenderService();
|
||||
|
||||
services.AddAutofac(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath);
|
||||
services.AddAutofac(hostContext.Configuration, logger, hostContext.HostingEnvironment.ContentRootPath);
|
||||
})
|
||||
.UseConsoleLifetime()
|
||||
.Build();
|
||||
|
@ -50,7 +50,7 @@ namespace ASC.Studio.Notify
|
||||
services.AddHostedService<ServiceLauncher>();
|
||||
diHelper.AddServiceLauncher();
|
||||
|
||||
services.AddAutofac(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath);
|
||||
services.AddAutofac(hostContext.Configuration, null, hostContext.HostingEnvironment.ContentRootPath);
|
||||
})
|
||||
.UseConsoleLifetime()
|
||||
.Build();
|
||||
|
@ -75,7 +75,7 @@ namespace ASC.UrlShortener.Svc
|
||||
services.AddHostedService<UrlShortenerServiceLauncher>();
|
||||
diHelper.AddUrlShortenerServiceLauncher();
|
||||
|
||||
services.AddAutofac(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath, false, false);
|
||||
services.AddAutofac(hostContext.Configuration, null, hostContext.HostingEnvironment.ContentRootPath, false, false);
|
||||
})
|
||||
.UseConsoleLifetime()
|
||||
.Build();
|
||||
|
@ -95,7 +95,7 @@ namespace ASC.Files
|
||||
.AddThirdPartyAppHandlerService()
|
||||
.AddDocuSignHandlerService();
|
||||
|
||||
services.AddAutofac(Configuration, HostEnvironment.ContentRootPath);
|
||||
services.AddAutofac(Configuration, null, HostEnvironment.ContentRootPath);
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
|
@ -58,7 +58,7 @@ namespace ASC.Files.Service
|
||||
.AddFactoryIndexerFolderService();
|
||||
|
||||
var a = typeof(FactoryIndexer<ISearchItem>).ToString();
|
||||
services.AddAutofac(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath, false, false, "search.json");
|
||||
services.AddAutofac(hostContext.Configuration, null, hostContext.HostingEnvironment.ContentRootPath, false, false, "search.json");
|
||||
})
|
||||
.UseConsoleLifetime()
|
||||
.Build();
|
||||
|
@ -117,7 +117,7 @@ namespace ASC.People
|
||||
.AddPeopleController()
|
||||
.AddGroupController();
|
||||
|
||||
services.AddAutofac(Configuration, HostEnvironment.ContentRootPath);
|
||||
services.AddAutofac(Configuration, null, HostEnvironment.ContentRootPath);
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
|
@ -89,7 +89,7 @@ namespace ASC.Web.Api
|
||||
.AddSettingsController()
|
||||
.AddSmtpSettingsController();
|
||||
|
||||
services.AddAutofac(Configuration, HostEnvironment.ContentRootPath);
|
||||
services.AddAutofac(Configuration, null, HostEnvironment.ContentRootPath);
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
|
@ -46,7 +46,7 @@ namespace ASC.Web.Studio
|
||||
.AddPathUtilsService()
|
||||
.AddStorageHandlerService();
|
||||
|
||||
services.AddAutofac(Configuration, HostEnvironment.ContentRootPath);
|
||||
services.AddAutofac(Configuration, null, HostEnvironment.ContentRootPath);
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
|
Loading…
Reference in New Issue
Block a user