コード例 #1
0
        public RubberduckParser()
        {
#if DEBUG
            LoggingConfigurator.ConfigureParserLogger();
#endif
            _logger = LogManager.GetCurrentClassLogger();
        }
コード例 #2
0
        public void CanUsePrivateConfiguration()
        {
            LoggingConfigurator.Configure("NoSuchFileHere");

            LoggingConfigurator.UsePrivateConfiguration = true;

            // There must be at least one repo, our private one:
            var repos = LogManager.GetAllRepositories();

            Assert.NotNull(repos);
            Assert.True(repos.Length > 0);

            const string repoName = "ProSuite.Commons";

            var repo = LogManager.GetRepository(repoName);

            Assert.NotNull(repo, $"Could not find our private repo: {repoName}");

            LoggingConfigurator.UsePrivateConfiguration = false;

            // Repo cannot be removed, but should have been shut down:
            Assert.NotNull(LogManager.GetRepository(repoName));

            // While at it: GetRepository() throws if given unknown name:
            Assert.Catch(() => LogManager.GetRepository("NoSuchLogRepo"));
        }
コード例 #3
0
ファイル: Startup.cs プロジェクト: KiranAKharade/Clipper
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                          .AddEnvironmentVariables();

            Configuration = builder.Build();

            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Async(a => a.File(LoggingConfigurator.GetConfiguration("EmployeeApi").Path + "EmployeeApi_log_.log",
                                                    rollingInterval: RollingInterval.Day, rollOnFileSizeLimit: true), blockWhenFull: true)
                         .Enrich.FromLogContext()
                         .MinimumLevel.ControlledBy(new LoggingLevelSwitch()
            {
                MinimumLevel = LogEventLevel.Information
            })
                         .Enrich.WithEnvironmentUserName()
                         .Enrich.WithMachineName()
                         .Enrich.WithThreadId()
                         .CreateLogger();

            Log.Information("EmployeeApi starting up...");
        }
コード例 #4
0
        public static IServiceCollection Add_doLittle(this IServiceCollection services)
        {
            var logAppenders = LoggingConfigurator.DiscoverAndConfigure(Internals.LoggerFactory);

            doLittle.Logging.ILogger logger = new Logger(logAppenders);

            var assembliesConfigurationBuilder = new AssembliesConfigurationBuilder();

            assembliesConfigurationBuilder.IncludeAll();

            var contractToImplementorsMap = new ContractToImplementorsMap();
            var executingAssembly         = typeof(doLittleModule).GetTypeInfo().Assembly;

            contractToImplementorsMap.Feed(executingAssembly.GetTypes());

            var assemblySpecifiers = new AssemblySpecifiers(assembliesConfigurationBuilder.RuleBuilder, logger);

            assemblySpecifiers.SpecifyUsingSpecifiersFrom(executingAssembly);

            var assembliesConfiguration = new AssembliesConfiguration(assembliesConfigurationBuilder.RuleBuilder);
            var assemblyFilters         = new AssemblyFilters(assembliesConfiguration);
            var assemblyProvider        = new AssemblyProvider(
                new ICanProvideAssemblies[] { new DefaultAssemblyProvider(logger) },
                assemblyFilters,
                new AssemblyUtility(),
                assemblySpecifiers);

            Internals.AllAssemblies           = assemblyProvider.GetAll();
            Internals.AssemblyFilters         = assemblyFilters;
            Internals.AssembliesConfiguration = assembliesConfiguration;
            Internals.AssemblyProvider        = assemblyProvider;
            Internals.Assemblies = new Assemblies(assemblyProvider);

            return(services);
        }
コード例 #5
0
        protected void Application_Start()
        {
            //MiniProfilerEF6.Initialize();
            string rootPath = HostingEnvironment.MapPath("~/App_Data/");

            if (!Directory.Exists(rootPath))
            {
                Directory.CreateDirectory(rootPath);
            }

            MvcHandler.DisableMvcResponseHeader = true;
            MappingConfig.RegisterMappings();
            GlobalFilters.Filters.Add(new CompressContentAttribute());
            var serviceLocator = new ServiceLocatorWeb();

            ServiceLocator.SetServiceLocator(serviceLocator);
            LoggingConfigurator.ConfigureNLog(serviceLocator);
            ModelMetadataProviders.Current = new ASMetadataProvider();
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            ModelBinders.Binders.Add(typeof(DateTime), new DateTimeModelBinder());
            ModelBinders.Binders.Add(typeof(DateTime?), new DateTimeModelBinder());
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            EFQueryLoggingConfig.Configure();

            //Fluent Validation
            ModelValidatorProviders.Providers.Add(new FluentValidationModelValidatorProvider(new ValidatorFactory())
            {
                AddImplicitRequiredValidator = false
            });
            DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
            DependencyResolver.Current.GetService <IInstallerService>().Install();
        }
コード例 #6
0
        private static IHost BuildHost(string[] commandlineArguments)
        {
            IConfigurationConfigurator configurationConfigurator = new ConfigurationConfigurator();
            ILoggingConfigurator       loggingConfigurator       = new LoggingConfigurator();
            IApplicationHostBuilder    hostBuilder = new ApplicationHostBuilder(configurationConfigurator, loggingConfigurator);

            return(hostBuilder.Build(commandlineArguments));
        }
コード例 #7
0
        public void Should_contain_Console_targets_if_printing_to_console()
        {
            var loggingSettings = new LoggingSettings("Test", true);

            LoggingConfigurator.ConfigureLogging(loggingSettings);

            var logConfiguration = NLog.LogManager.Configuration;

            Assert.IsNotEmpty(logConfiguration.LoggingRules.Where(rule => rule.Targets.Any(target => target is ColoredConsoleTarget)));
        }
コード例 #8
0
 private static void ConfigureLogging()
 {
     if (!AppConfigurationSettings.IsProductionEnvironment)
     {
         LoggingConfigurator.AddAppenderBuilder <ConsoleAppenderBuilder>();
     }
     LoggingConfigurator.AddAppenderBuilder <FileAppenderBuilder>();
     //LoggingConfigurator.AddAppenderBuilder<AdoNetAppenderBuilder>();
     LoggingConfigurator.Configure();
 }
コード例 #9
0
        public void CanConfigure()
        {
            const string fileName   = "NoSuchFileHere";
            var          searchDirs = new string[0];
            const bool   useDefaultConfiguration = true;

            // Must not throw because a log config file is considered optional!
            LoggingConfigurator.Configure(fileName, searchDirs, useDefaultConfiguration);

            // Since we used the default config, logging must still be configured!
            Assert.True(LoggingConfigurator.IsConfigured());
        }
コード例 #10
0
ファイル: Startup.cs プロジェクト: abmes/Abmes.DataCollector
        // This method gets called by the runtime. Use this method to add services to the container
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            services.AddOptions();
            services.AddLogging(loggingBuilder =>
            {
                LoggingConfigurator.Configure(loggingBuilder, Configuration);
            });

            ServicesConfiguration.Configure(services, Configuration);
        }
コード例 #11
0
        public static void Configure([NotNull] string configFileName,
                                     bool useDefaultConfiguration            = true,
                                     bool dontOverwriteExistingConfiguration = false)
        {
            Assert.ArgumentNotNullOrEmpty(configFileName, nameof(configFileName));

            var directorySearcher = new AppDirectorySearcher(
                ConfigurationUtils.CompanyName,
                ConfigurationUtils.ProductName,
                ConfigurationUtils.GetInstallDirectory().FullName);

            LoggingConfigurator.Configure(configFileName,
                                          directorySearcher.GetSearchPaths(),
                                          useDefaultConfiguration,
                                          dontOverwriteExistingConfiguration);
        }
コード例 #12
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton <IConfiguration>(Configuration);

            services.AddOptions();
            services.AddLogging(loggingBuilder =>
            {
                //var loggingConfigSection = Configuration.GetSection(Configuration["Logging"]);
                //loggingBuilder.AddConfiguration(loggingConfigSection);
                //loggingBuilder.AddConsole();
                loggingBuilder.AddProvider(new Logging.CollectorConsoleLoggingProvider());
                loggingBuilder.AddDebug();

                LoggingConfigurator.Configure(loggingBuilder, Configuration);
            });

            ServicesConfiguration.Configure(services, Configuration);
        }
コード例 #13
0
        public static void ConfigureLogging(bool verboseRequired,
                                            [NotNull] string logConfigFileName)
        {
            int processId = Process.GetCurrentProcess().Id;

            LoggingConfigurator.SetGlobalProperty("LogFileSuffix", $"PID_{processId}");

            LoggingConfigurator.Configure(logConfigFileName,
                                          GetLogConfigPaths(),
                                          useDefaultConfiguration: true);

            _msg.ReportMemoryConsumptionOnError = true;

            bool verboseLogging =
                verboseRequired ||
                EnvironmentUtils.GetBooleanEnvironmentVariableValue(_verboseLoggingEnvVar);

            if (verboseLogging)
            {
                _msg.DebugFormat("Verbose logging configured by env var ({0})",
                                 _verboseLoggingEnvVar);

                _msg.IsVerboseDebugEnabled = true;
            }

            Assembly exeAssembly = Assert.NotNull(Assembly.GetEntryAssembly());

            string bitness = Environment.Is64BitProcess ? "64 bit" : "32 bit";

            _msg.InfoFormat("Logging configured for {0} ({1}) version {2}",
                            exeAssembly.Location, bitness,
                            exeAssembly.GetName().Version);

            if (_msg.IsVerboseDebugEnabled)
            {
                _msg.Debug("Environment variables:");

                foreach (DictionaryEntry de in Environment.GetEnvironmentVariables())
                {
                    _msg.DebugFormat("  {0} = {1}", de.Key, de.Value);
                }
            }
        }
コード例 #14
0
        static async Task Main(string[] args)
        {
            AppDomain.CurrentDomain.AssemblyResolve += (s, e) => ResolveAssembly(e.Name);

            var arguments = new HostArguments(args);

            if (arguments.Help)
            {
                arguments.PrintUsage();
                return;
            }

            var loggingSettings = new LoggingSettings(arguments.ServiceName, false);

            LoggingConfigurator.ConfigureLogging(loggingSettings);

            await new CommandRunner(arguments.Commands).Execute(arguments)
            .ConfigureAwait(false);
        }
コード例 #15
0
ファイル: Startup.cs プロジェクト: abmes/Abmes.DataCollector
        // This method gets called by the runtime. Use this method to add services to the container
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            services.AddOptions();
            services.AddLogging(loggingBuilder =>
            {
                LoggingConfigurator.Configure(loggingBuilder);
            });

            var identityServerAuthenticationSettings =
                Configuration
                .GetSection("IdentityServerAuthenticationSettings")
                .Get <IdentityServerAuthenticationSettings>();

            services
            .AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
            .AddIdentityServerAuthentication(x =>
            {
                x.Authority            = identityServerAuthenticationSettings.Authority;
                x.ApiName              = identityServerAuthenticationSettings.ApiName;
                x.ApiSecret            = identityServerAuthenticationSettings.ApiSecret;
                x.RequireHttpsMetadata = false;
            });

            services.AddAuthorization(options =>
            {
                options.AddPolicy("UserAllowedDataCollection", policy =>
                {
                    policy.RequireAuthenticatedUser();
                    policy.Requirements.Add(new UserAllowedDataCollectionRequirement());
                }
                                  );
            });

            services.AddSingleton <IAuthorizationHandler, UserAllowedDataCollectionHandler>();

            ServicesConfiguration.Configure(services, Configuration);
        }
コード例 #16
0
        public static void ConfigureUnittestLogging()
        {
            List <string> logDirs = new List <string>();

            string currentDir = Environment.CurrentDirectory;

            if (Directory.Exists(currentDir))
            {
                logDirs.Add(currentDir);
            }

            string assemblyDir =
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            Assert.IsNotNull(assemblyDir);
            if (Directory.Exists(assemblyDir))
            {
                logDirs.Add(assemblyDir);

                DirectoryInfo parent = Directory.GetParent(assemblyDir);
                if (parent?.Exists == true)
                {
                    logDirs.Add(parent.FullName);
                }
            }

            if (!LoggingConfigurator.Configure(_loggingConfigurationFile, logDirs))
            {
                Console.WriteLine("Logging configurator failed.");
                Console.WriteLine("logging configuration file: " + _loggingConfigurationFile);
                Console.WriteLine("Search directories: " + StringUtils.Concatenate(logDirs, ", "));
            }
            else
            {
                Console.WriteLine("Logging configured.");
            }
        }
コード例 #17
0
        protected override void Load(ContainerBuilder builder)
        {
            var selfBindingRegistrationSource = new AnyConcreteTypeNotAlreadyRegisteredSource(type =>
                                                                                              !type.Namespace.StartsWith("Microsoft") &&
                                                                                              !type.Namespace.StartsWith("System"));

            var logAppenders = LoggingConfigurator.DiscoverAndConfigure(Internals.LoggerFactory);

            doLittle.Logging.ILogger logger = new Logger(logAppenders);
            builder.RegisterType <Logger>().As <doLittle.Logging.ILogger>().SingleInstance();

            builder.RegisterType <ControllerActionCommandContextManager>().As <ICommandContextManager>().SingleInstance();

            builder.RegisterGeneric(typeof(InstancesOf <>)).As(typeof(IInstancesOf <>));
            builder.RegisterGeneric(typeof(ImplementationsOf <>)).As(typeof(IImplementationsOf <>));
            builder.RegisterGeneric(typeof(AggregateRootRepositoryFor <>)).As(typeof(IAggregateRootRepositoryFor <>));

            builder.RegisterInstance(Internals.AssemblyFilters).As <IAssemblyFilters>();
            builder.RegisterInstance(Internals.AssembliesConfiguration).As <AssembliesConfiguration>();
            builder.RegisterInstance(Internals.AssemblyProvider).As <IAssemblyProvider>();
            builder.RegisterInstance(Internals.Assemblies).As <IAssemblies>();

            builder.RegisterType <ConvertersProvider>().AsSelf();

            //Internals.Assemblies.GetAll().ForEach(assembly => builder.RegisterAssemblyTypes(assembly).AsSelf().AsImplementedInterfaces());

            builder.RegisterType <Container>().As <doLittle.DependencyInversion.IContainer>().SingleInstance();
            builder.RegisterType <UncommittedEventStreamCoordinator>().As <IUncommittedEventStreamCoordinator>()
            .SingleInstance();
            builder.RegisterType <Infrastructure.AspNet.EventProcessors>().As <IEventProcessors>().SingleInstance();
            builder.RegisterType <NullEventProcessorLog>().As <IEventProcessorLog>().SingleInstance();
            builder.RegisterType <NullEventProcessorStates>().As <IEventProcessorStates>().SingleInstance();
            builder.RegisterType <NullEventStore>().As <IEventStore>().SingleInstance();
            builder.RegisterType <NullEventSourceVersions>().As <IEventSourceVersions>().SingleInstance();
            builder.RegisterType <NullEventSequenceNumbers>().As <IEventSequenceNumbers>().SingleInstance();

            builder.RegisterType <CommittedEventStreamSender>().As <ICanSendCommittedEventStream>().SingleInstance();
            builder.RegisterType <CommittedEventStreamReceiver>().As <ICanReceiveCommittedEventStream>().SingleInstance();
            builder.RegisterType <CommittedEventStreamBridge>().As <ICommittedEventStreamBridge>().SingleInstance();
            builder.RegisterType <CommittedEventStreamCoordinator>().As <ICommittedEventStreamCoordinator>().SingleInstance();
            builder.RegisterType <ProcessMethodEventProcessors>().AsSelf().SingleInstance();

            var applicationStructureBuilder =
                new ApplicationStructureConfigurationBuilder()
                .Include(ApplicationAreas.Domain, "Infrastructure.AspNet.-{BoundedContext}.-{Module}.-{Feature}.^{SubFeature}*")
                .Include(ApplicationAreas.Domain, "Infrastructure.Kafka.BoundedContexts.-{BoundedContext}.-{Module}.-{Feature}.^{SubFeature}*")
                .Include(ApplicationAreas.Domain, "Domain.-{BoundedContext}.-{Module}.-{Feature}.^{SubFeature}*")
                .Include(ApplicationAreas.Events, "Events.-{BoundedContext}.-{Module}.-{Feature}.^{SubFeature}*")
                .Include(ApplicationAreas.Read, "Read.-{BoundedContext}.-{Module}.-{Feature}.^{SubFeature}*");

            var applicationStructure = applicationStructureBuilder.Build();
            var applicationName      = (ApplicationName)"CBS";
            var application          = new Application(applicationName, applicationStructure);

            builder.Register(_ => application).As <IApplication>().SingleInstance();
            builder.Register(_ => Internals.BoundedContext).AsSelf();

            var identity = new ClaimsIdentity();

            identity.AddClaim(new Claim(identity.NameClaimType, "[Anonymous]"));
            var principal = new ClaimsPrincipal(identity);

            var tenant = new Tenant("IFRC");

            builder.RegisterInstance(tenant).As <ITenant>();

            builder.Register(_ =>
                             new doLittle.Runtime.Execution.ExecutionContext(
                                 principal,
                                 CultureInfo.InvariantCulture,
                                 (context, details) => { },
                                 application,
                                 tenant)
                             ).As <IExecutionContext>();

            builder.RegisterSource(new EventProcessorRegistrationSource());
        }
コード例 #18
0
        static void Main(string[] args)
        {
            try
            {
                var localObject = new RemoteObject();
                Console.WriteLine("Local object - Main Module Location: {0}", localObject.GetProcessMainModuleFileName());
                Console.WriteLine("Local object - App.config location: {0}", localObject.GetAppConfigLocation());
                Console.WriteLine("Local object - App.config value: {0}", localObject.GetAppConfigValue("MyString"));

                var setup = new ProcessDomainSetup
                {
                    ProcessStartTimeout = new TimeSpan(0, 0, 5),
                };

                using (ProcessDomain processDomain = ProcessDomain.CreateDomain("RemoteProcess", setup))
                {
                    LoggingConfigurator.CreateConfigurator(processDomain).ConfigureAppConfig();

                    var remoteObject = (RemoteObject)processDomain.CreateInstanceAndUnwrap(typeof(RemoteObject).Assembly.FullName, typeof(RemoteObject).FullName);
                    Console.WriteLine("Remote object - Main Module Location: {0}", remoteObject.GetProcessMainModuleFileName());
                    Console.WriteLine("Remote object - App.config location: {0}", remoteObject.GetAppConfigLocation());
                    Console.WriteLine("Remote object - App.config value: {0}", remoteObject.GetAppConfigValue("MyString"));

                    var detachedEvent = new ManualResetEvent(false);
                    var attachedEvent = new ManualResetEvent(false);
                    processDomain.Detached += () => detachedEvent.Set();
                    processDomain.Attached += () =>
                    {
                        LoggingConfigurator.CreateConfigurator(processDomain).ConfigureAppConfig();
                        attachedEvent.Set();
                    };

                    Console.WriteLine("Finding RemoteProcess and killing it...");
                    Process.GetProcessesByName("RemoteProcess").FirstOrDefault().Kill();

                    if (!detachedEvent.WaitOne(10000))
                    {
                        throw new Exception("Timed-out while waiting for process to die");
                    }

                    Console.WriteLine("Waiting for new process to spawn");
                    if (!attachedEvent.WaitOne(10000))
                    {
                        throw new Exception("Timed-out while waiting for process to restart");
                    }

                    Console.WriteLine("Re-creating remote object in newly spawned process");
                    remoteObject = (RemoteObject)processDomain.CreateInstanceAndUnwrap(typeof(RemoteObject).Assembly.FullName, typeof(RemoteObject).FullName);
                    Console.WriteLine("Remote object - Main Module Location: {0}", remoteObject.GetProcessMainModuleFileName());
                    Console.WriteLine("Remote object - App.config location: {0}", remoteObject.GetAppConfigLocation());
                    Console.WriteLine("Remote object - App.config value: {0}", remoteObject.GetAppConfigValue("MyString"));

                    Console.WriteLine("Throwing an exception...");
                    try
                    {
                        remoteObject.ThrowException();
                        Console.WriteLine("Did not catch an exception...");
                    }
                    catch (RemoteException rex)
                    {
                        Console.WriteLine("Caught exception: {0}", rex.Message);
                    }
                }

                Console.WriteLine("Two process domains at the same time");

                using (var processDomain1 = ProcessDomain.CreateDomain("RemoteProcess1", setup))
                    using (var processDomain2 = ProcessDomain.CreateDomain("RemoteProcess2", setup))
                    {
                        var remoteObject1 = (RemoteObject)processDomain1.CreateInstanceAndUnwrap(typeof(RemoteObject).Assembly.FullName, typeof(RemoteObject).FullName);
                        var remoteObject2 = (RemoteObject)processDomain2.CreateInstanceAndUnwrap(typeof(RemoteObject).Assembly.FullName, typeof(RemoteObject).FullName);

                        Console.WriteLine("Remote object #1 - App.config value: {0}", remoteObject1.GetAppConfigValue("MyString"));
                        Console.WriteLine("Remote object #2 - App.config value: {0}", remoteObject2.GetAppConfigValue("MyString"));
                    }

                Console.WriteLine("Process domain in alternate location");
                setup.AppDomainSetupInformation.ApplicationBase = @"c:\";
                setup.ExternalAssemblies[typeof(Program).Assembly.GetName()] = typeof(Program).Assembly.Location;
                using (var processDomain = ProcessDomain.CreateDomain("RemoteProcess", setup))
                {
                    var remoteObject = (RemoteObject)processDomain.CreateInstanceAndUnwrap(typeof(RemoteObject).Assembly.FullName, typeof(RemoteObject).FullName);

                    Console.WriteLine("Remote object - App.config value: {0}", remoteObject.GetAppConfigValue("MyString"));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: {0}", ex);
            }

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
コード例 #19
0
        /// <summary>
        /// Configure by letting Bifrost discover anything that implements the discoverable configuration interfaces
        /// </summary>
        /// <returns></returns>
        public static Configure DiscoverAndConfigure(
#if (!NET461)
            ILoggerFactory loggerFactory,
#endif
            Action <AssembliesConfigurationBuilder> assembliesConfigurationBuilderCallback = null,
            IEnumerable <ICanProvideAssemblies> additionalAssemblyProviders = null)
        {
#if (NET461)
            var logAppenders = LoggingConfigurator.DiscoverAndConfigure();
#else
            var logAppenders = LoggingConfigurator.DiscoverAndConfigure(loggerFactory);
#endif
            Logging.ILogger logger = new Logger(logAppenders);
            logger.Information("Starting up");

            IContractToImplementorsMap contractToImplementorsMap;


            var assembliesConfigurationBuilder = BuildAssembliesConfigurationIfCallbackDefined(assembliesConfigurationBuilderCallback);

            logger.Trace("Settings up contract to implementors map");

            contractToImplementorsMap = new ContractToImplementorsMap();
            var executingAssembly = typeof(Configure).GetTypeInfo().Assembly;
            contractToImplementorsMap.Feed(executingAssembly.GetTypes());

            logger.Trace("Specifying which assemblies to include");
            var assemblySpecifiers = new AssemblySpecifiers(contractToImplementorsMap, new TypeFinder(), assembliesConfigurationBuilder.RuleBuilder);
            assemblySpecifiers.SpecifyUsingSpecifiersFrom(executingAssembly);

            var assemblyProviders = new List <ICanProvideAssemblies>
            {
#if (NET461)
                new AppDomainAssemblyProvider(logger),
#else
                new DefaultAssemblyProvider(logger),
#endif
                new FileSystemAssemblyProvider(new FileSystem(), logger)
            };


            if (additionalAssemblyProviders != null)
            {
                assemblyProviders.AddRange(additionalAssemblyProviders);
            }

            var assembliesConfiguration = new AssembliesConfiguration(assembliesConfigurationBuilder.RuleBuilder);
            var assemblyProvider        = new AssemblyProvider(
                assemblyProviders,
                new AssemblyFilters(assembliesConfiguration),
                new AssemblyUtility(),
                assemblySpecifiers,
                contractToImplementorsMap,
                logger);

            var assemblies = assemblyProvider.GetAll();

            var canCreateContainerType = DiscoverCanCreateContainerType(assemblies);
            ThrowIfCanCreateContainerNotFound(canCreateContainerType);
            ThrowIfCanCreateContainerDoesNotHaveDefaultConstructor(canCreateContainerType);
            var canCreateContainerInstance = Activator.CreateInstance(canCreateContainerType) as ICanCreateContainer;
            var container = canCreateContainerInstance.CreateContainer();

            container.Bind(logAppenders);
            container.Bind(logger);

            var configure = With(
                container,
                assembliesConfiguration,
                assemblyProvider,
                contractToImplementorsMap);
            configure.EntryAssembly = canCreateContainerType.GetTypeInfo().Assembly;
            configure.Initialize();
            return(configure);
        }
コード例 #20
0
 private static void ConfigureLogging()
 {
     LoggingConfigurator.AddAppenderBuilder <FileAppenderBuilder>();
     LoggingConfigurator.Configure();
 }
コード例 #21
0
        /// <summary>
        /// Configures NDomain framework with NLog.
        /// </summary>
        /// <param name="configurator">logging configurator</param>
        /// <returns>Current configurator instance, to be used in a fluent manner</returns>
        public static LoggingConfigurator WithNLog(this LoggingConfigurator configurator)
        {
            configurator.LoggerFactory = new LoggerFactory();

            return(configurator);
        }