Skip to content

Commit 2ce4a61

Browse files
committed
Moving up log init; leaving more breadcrumbs in startup process
1 parent 24e41d4 commit 2ce4a61

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Agent/NewRelic/Agent/Core/AgentManager.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ public static IAgentManager Instance
9191
/// </remarks>
9292
private AgentManager()
9393
{
94+
Log.Initialize(new NewRelic.Core.Logging.FileLogger(new configurationLog().GetFullLogFileName()));
95+
96+
Log.Info("AgentManager() constructor");
97+
9498
_container = AgentServices.GetContainer();
9599
AgentServices.RegisterServices(_container);
96100

@@ -99,6 +103,7 @@ private AgentManager()
99103

100104
configuration config = null;
101105

106+
Log.Info("Initializing ConfigurationLoader");
102107
try
103108
{
104109
config = ConfigurationLoader.Initialize();
@@ -118,13 +123,17 @@ private AgentManager()
118123

119124
LoggerBootstrapper.ConfigureLogger(config.LogConfig);
120125

126+
Log.Info("Checking AgentEnabled...");
121127
AssertAgentEnabled(config);
122128

129+
Log.Info("Subscribing to Shutdown signal");
123130
EventBus<KillAgentEvent>.Subscribe(OnShutdownAgent);
124131

132+
Log.Info("Initializing extensions");
125133
//Initialize the extensions loader with extensions folder based on the the install path
126134
ExtensionsLoader.Initialize(AgentInstallConfiguration.InstallPathExtensionsDirectory);
127135

136+
Log.Info("Resolving API and wrapper services");
128137
// Resolve all services once we've ensured that the agent is enabled
129138
// The AgentApiImplementation needs to be resolved before the WrapperService, because
130139
// resolving the WrapperService triggers an agent connect but it doesn't instantiate
@@ -136,15 +145,19 @@ private AgentManager()
136145
var agentApi = _container.Resolve<IAgentApi>();
137146
_wrapperService = _container.Resolve<IWrapperService>();
138147

148+
Log.Info("Resolving AutoStart");
139149
//We need to attempt to auto start the agent once all services have resolved
140150
_container.Resolve<IConnectionManager>().AttemptAutoStart();
141151

152+
Log.Info("Starting services");
142153
AgentServices.StartServices(_container);
143154

155+
Log.Info("API setup");
144156
// Setup the internal API first so that AgentApi can use it.
145157
InternalApi.SetAgentApiImplementation(agentApi);
146158
AgentApi.SetSupportabilityMetricCounters(_container.Resolve<IApiSupportabilityMetricCounters>());
147159

160+
Log.Info("Initialize()");
148161
Initialize();
149162
_isInitialized = true;
150163
}
@@ -165,6 +178,7 @@ private void Initialize()
165178
var nativeMethods = _container.Resolve<INativeMethods>();
166179
var instrumentationService = _container.Resolve<IInstrumentationService>();
167180

181+
Log.Info("Staring thread profiler");
168182
_threadProfilingService = new ThreadProfilingService(_container.Resolve<IDataTransportService>(), nativeMethods);
169183

170184
var commandService = _container.Resolve<CommandService>();
@@ -176,6 +190,7 @@ private void Initialize()
176190
new InstrumentationUpdateCommand(instrumentationService)
177191
);
178192

193+
Log.Info("Starting services");
179194
StartServices();
180195
LogInitialized();
181196
}

src/Agent/NewRelic/Agent/Core/Logging/LoggerBootstrapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static void ConfigureLogger(ILogConfig config)
7878

7979
Log.Logger = configuredLogger;
8080

81-
NewRelic.Core.Logging.Log.Initialize(new NewRelic.Core.Logging.FileLogger(config.GetFullLogFileName()));
81+
//NewRelic.Core.Logging.Log.Initialize(new NewRelic.Core.Logging.FileLogger(config.GetFullLogFileName()));
8282
}
8383

8484
private static void EchoInMemoryLogsToConfiguredLogger(ILogger configuredLogger)

0 commit comments

Comments
 (0)