diff --git a/src/Agent/NewRelic/Agent/Core/AgentInstallConfiguration.cs b/src/Agent/NewRelic/Agent/Core/AgentInstallConfiguration.cs index 01b8b64766..fa8418e7ab 100644 --- a/src/Agent/NewRelic/Agent/Core/AgentInstallConfiguration.cs +++ b/src/Agent/NewRelic/Agent/Core/AgentInstallConfiguration.cs @@ -200,18 +200,27 @@ private static string GetNewRelicLogLevel() public static AgentInfo GetAgentInfo() { - var agentInfoPath = $@"{NewRelicHome}\agentinfo.json"; + if (string.IsNullOrEmpty(NewRelicHome)) + { + Log.Debug($"Could not get agent info. NewRelicHome is null or empty."); + return null; + } + + var agentInfoPath = Path.Combine(NewRelicHome, "agentinfo.json"); + if (File.Exists(agentInfoPath)) { try { return JsonConvert.DeserializeObject(File.ReadAllText(agentInfoPath)); } - catch + catch (Exception e) { - // Fail silently + Log.Debug(e, $"Could not deserialize agent info from {agentInfoPath}."); } } + else + Log.Debug($"Could not get agent info from {agentInfoPath}. File does not exist."); return null; }