private static void RegisterNLogOnly(string message, ConfigurationDto objConfiguration, EnumNLogStruct.LogType typeOfLog) { var finalMessage = BuildLogInfoWithConfigurationInformation(objConfiguration, false); if (!object.ReferenceEquals(objConfiguration, null)) { if (object.ReferenceEquals(objLogger, null)) { objLogger = new LogManagerContainer().GetAnyInstance <ILoggerConfigurable <Logger> >(); } objLogger.RegisterLogWithCustomInfo(typeOfLog, new LogVo() { CustomMessage = string.Concat(finalMessage, message), CustomType = typeOfLog }); } }
/// <summary> /// register all type of information when AppDynamics extension is running. Also, trace /// all information from execution environment. /// </summary> /// <param name="message"></param> /// <param name="option"></param> public static void RegisterLogFacade(string message, EnumNLogStruct.TypeOfRegister option, EnumNLogStruct.LogType typeOfLog, bool withPrefix) { ConfigurationDto objConfigurationGlobal = default(ConfigurationDto); objLogger = new LogManagerContainer().GetAnyInstance <ILoggerConfigurable <Logger> >(); string prefix = default(string); if (!string.IsNullOrEmpty(message)) { try { objConfigurationGlobal = new ConfigurationManager().LoadInitialConfiguration(); if (!object.ReferenceEquals(objConfigurationGlobal, null)) { prefix = withPrefix ? $"[AppDynamics CCO Extension on " + $"{objConfigurationGlobal.ExecutionInformation.EnvironmentInfo.MachineHostName} \t" + $"({objConfigurationGlobal.ExecutionInformation.TrackingUsingInfo.IpAddress}) at: \t" + $"{DateTime.Now.ToLongDateString()} says: \n" : string.Empty; ; var fixedFinalMessage = string.Concat(prefix, message); switch (option) { case EnumNLogStruct.TypeOfRegister.NLog: RegisterNLogOnly(fixedFinalMessage, objConfigurationGlobal, typeOfLog); break; case EnumNLogStruct.TypeOfRegister.Console: RegisterConsoleLog(fixedFinalMessage, objConfigurationGlobal, typeOfLog); break; case EnumNLogStruct.TypeOfRegister.All: RegisterConsoleLog(fixedFinalMessage, objConfigurationGlobal, typeOfLog); RegisterNLogOnly(fixedFinalMessage, objConfigurationGlobal, typeOfLog); break; default: throw new ArgumentOutOfRangeException(nameof(option), option, null); } } else { objLogger.RegisterLogWithCustomInfo(EnumNLogStruct.LogType.Warning, new LogVo() { CustomMessage = "[AppDynamics CCO Extension]: Cannot load configuration from execution environment" }); } } catch (Exception ex) { objLogger.RegisterLogWithCustomInfo(EnumNLogStruct.LogType.Error, new LogVo() { Exception = ex, CustomMessage = ex.Message }); } } }
/// <summary> /// register all type of information when AppDynamics extension is running. Also, trace /// all information from execution environment. /// </summary> /// <param name="message"></param> /// <param name="option"></param> public static void RegisterLogFacade(string message, EnumNLogStruct.TypeOfRegister option, EnumNLogStruct.LogType typeOfLog, bool withPrefix) { ConfigurationDto objConfigurationGlobal = default(ConfigurationDto); objLogger = new LogManagerContainer().GetAnyInstance<ILoggerConfigurable<Logger>>(); string prefix = default(string); if (!string.IsNullOrEmpty(message)) { try { objConfigurationGlobal = new ConfigurationManager().LoadInitialConfiguration(); if (!object.ReferenceEquals(objConfigurationGlobal, null)) { prefix = withPrefix ? $"[AppDynamics CCO Extension on " + $"{objConfigurationGlobal.ExecutionInformation.EnvironmentInfo.MachineHostName} \t" + $"({objConfigurationGlobal.ExecutionInformation.TrackingUsingInfo.IpAddress}) at: \t" + $"{DateTime.Now.ToLongDateString()} says: \n" : string.Empty; ; var fixedFinalMessage = string.Concat(prefix, message); switch (option) { case EnumNLogStruct.TypeOfRegister.NLog: RegisterNLogOnly(fixedFinalMessage, objConfigurationGlobal, typeOfLog); break; case EnumNLogStruct.TypeOfRegister.Console: RegisterConsoleLog(fixedFinalMessage, objConfigurationGlobal, typeOfLog); break; case EnumNLogStruct.TypeOfRegister.All: RegisterConsoleLog(fixedFinalMessage, objConfigurationGlobal, typeOfLog); RegisterNLogOnly(fixedFinalMessage, objConfigurationGlobal, typeOfLog); break; default: throw new ArgumentOutOfRangeException(nameof(option), option, null); } } else { objLogger.RegisterLogWithCustomInfo(EnumNLogStruct.LogType.Warning, new LogVo() { CustomMessage = "[AppDynamics CCO Extension]: Cannot load configuration from execution environment" }); } } catch (Exception ex) { objLogger.RegisterLogWithCustomInfo(EnumNLogStruct.LogType.Error, new LogVo() { Exception = ex, CustomMessage = ex.Message }); } } }