示例#1
0
        public static void IsEnabledFor_finest_is_false_when_config_log_is_debug()
        {
            ILogConfig config = GetLogConfig("debug");

            LoggerBootstrapper.Initialize();
            LoggerBootstrapper.ConfigureLogger(config);
            Assert.IsFalse(Log.IsFinestEnabled);
        }
示例#2
0
        public static void IsDebugEnabled_is_false_when_config_log_is_info()
        {
            ILogConfig config = GetLogConfig("info");

            LoggerBootstrapper.Initialize();
            LoggerBootstrapper.ConfigureLogger(config);
            Assert.IsFalse(Log.IsDebugEnabled);
        }
示例#3
0
        public static void IsDebugEnabled_is_true_when_config_log_is_debug()
        {
            ILogConfig config = GetLogConfig("debug");

            LoggerBootstrapper.Initialize();
            LoggerBootstrapper.ConfigureLogger(config);
            Assert.That(Log.IsDebugEnabled);
        }
            static CallOnce()
            {
                // we must ensure that we hook up to ProcessExit and DomainUnload *before* log4net.  Otherwise we can't log anything during OnExit.
                AppDomain.CurrentDomain.ProcessExit  += (sender, args) => OnExit(sender, args);
                AppDomain.CurrentDomain.DomainUnload += (sender, args) => OnExit(sender, args);
                LoggerBootstrapper.Initialize();

                // Force agent to be initialized
                var agent = AgentManager.Instance;
            }
        /// <summary>
        /// Creates an instance of the <see cref="AgentManager"/> class./>
        /// </summary>
        /// <remarks>
        /// The agent should be constructed as early as possible in order to perform
        /// initialization of the logging system.
        /// </remarks>
        private AgentManager()
        {
            _container = AgentServices.GetContainer();
            AgentServices.RegisterServices(_container);

            // Resolve IConfigurationService (so that it starts listening to config changes) before loading newrelic.config
            _container.Resolve <IConfigurationService>();
            var config = ConfigurationLoader.Initialize();

            LoggerBootstrapper.ConfigureLogger(config.LogConfig);

            AssertAgentEnabled(config);

            EventBus <KillAgentEvent> .Subscribe(OnShutdownAgent);

            //Initialize the extensions loader with extensions folder based on the the install path
            ExtensionsLoader.Initialize(AgentInstallConfiguration.InstallPathExtensionsDirectory);

            // Resolve all services once we've ensured that the agent is enabled
            // The AgentApiImplementation needs to be resolved before the WrapperService, because
            // resolving the WrapperService triggers an agent connect but it doesn't instantiate
            // the CustomEventAggregator, so we need to resolve the AgentApiImplementation to
            // get the CustomEventAggregator instantiated before the connect process is triggered.
            // If that doesn't happen the CustomEventAggregator will not start its harvest timer
            // when the agent connect response comes back. The agent DI, startup, and connect
            // process really needs to be refactored so that it's more explicit in its behavior.
            var agentApi = _container.Resolve <IAgentApi>();

            _wrapperService = _container.Resolve <IWrapperService>();

            //We need to attempt to auto start the agent once all services have resolved
            _container.Resolve <IConnectionManager>().AttemptAutoStart();

            AgentServices.StartServices(_container);

            // Setup the internal API first so that AgentApi can use it.
            InternalApi.SetAgentApiImplementation(agentApi);
            AgentApi.SetSupportabilityMetricCounters(_container.Resolve <IApiSupportabilityMetricCounters>());

            Initialize();
            _isInitialized = true;
        }