public static void WriteEnabledDisabledFunctions(ConfigurationDto objConfiguration) { var allConfiguration = new ConfigurationManager().LoadInitialConfiguration(); if (!object.ReferenceEquals(allConfiguration, null)) { RegisterLogFacade(string.Format("ScriptRunner is: [{0}] \n", allConfiguration.ScripRunnerSettings.IsEnabled ? "Enabled" : "Disabled"), EnumNLogStruct.TypeOfRegister.All, EnumNLogStruct.LogType.Info, true); RegisterLogFacade(string.Format("IIS Recycler is: [{0}] \n", allConfiguration.IISRecyclerConfiguration.IsEnabled ? "Enabled" : "Disabled"), EnumNLogStruct.TypeOfRegister.All, EnumNLogStruct.LogType.Info, true); RegisterLogFacade(string.Format("IIS Restarter is: [{0}] \n", allConfiguration.IISRestarterConfiguration.IsEnabled ? "Enabled" : "Disabled"), EnumNLogStruct.TypeOfRegister.All, EnumNLogStruct.LogType.Info, true); RegisterLogFacade(string.Format("Event Log Manager is: [{0}] \n", allConfiguration.EventLogManager.IsEnabled ? "Enabled" : "Disabled"), EnumNLogStruct.TypeOfRegister.All, EnumNLogStruct.LogType.Info, true); } }
static void Main(string[] args) { LogAndConsoleTracker.RegisterLogFacade("AppDynamics Extension Launched \n", transversal.dto.Enums.Nlog.EnumNLogStruct.TypeOfRegister.All, transversal.dto.Enums.Nlog.EnumNLogStruct.LogType.Info, true); var objConfiguration = new ConfigurationManager().LoadInitialConfiguration(); LogAndConsoleTracker.WriteEnabledDisabledFunctions(objConfiguration); TaskRunner(objConfiguration); }
/// <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 }); } } }
public void LoadInitialConfigurationTest() { var confiTest = new ConfigurationManager(); Assert.IsNotNull(confiTest.LoadInitialConfiguration()); }