private static void Configure(INewRelicConfig config) { config = config ?? NewRelicConfig.Instance; LoggingConfiguration loggingConfiguration = new LoggingConfiguration(); ColoredConsoleTarget consoleTarget = new ColoredConsoleTarget { Name = "Console" }; loggingConfiguration.AddTarget("Console", consoleTarget); loggingConfiguration.LoggingRules.Add(new LoggingRule("*", ToNLogLevel(config.LogLevel), consoleTarget)); // Store the LogLevel so it can be fetched by consumers LogLevel = config.LogLevel; if (config.LogFilePath.IsValidString() && config.LogFileName.IsValidString()) { long archiveAboveSize = config.LogLimitInKiloBytes == 0 ? long.MaxValue : config.LogLimitInKiloBytes * 1024; FileTarget fileTarget = new FileTarget { KeepFileOpen = true, ConcurrentWrites = false, FileName = Path.Combine(config.LogFilePath, config.LogFileName), MaxArchiveFiles = 1, ArchiveAboveSize = archiveAboveSize, Name = "File", }; loggingConfiguration.AddTarget("File", fileTarget); loggingConfiguration.LoggingRules.Add(new LoggingRule("*", ToNLogLevel(config.LogLevel), fileTarget)); } NLogManager.Configuration = loggingConfiguration; }
/// <summary> /// This class is responsible for maintaining metrics that have been reported as well as sending them to the New Relic /// service. Any Components that share a Request reference will have their data sent to the service in one request. /// </summary> /// <param name="licenseKey">The New Relic license key.</param> /// <param name="config">The configuration that should be used.</param> public Context(string licenseKey, INewRelicConfig config = null) { this._newRelicConfig = config ?? NewRelicConfig.Instance; this._licenseKey = licenseKey; this._requestData = new RequestData(); s_log.Debug("Using service URL: {0}", this.ServiceUri); s_log.Debug("Using license key: {0}", this.LicenseKey); }
// methods in this region should only be called directly by tests #region CalledByTests internal static Logger GetLogger(string className, INewRelicConfig config) { if (!Configured || config != null) { lock (ConfigureLock) { if (!Configured || config != null) { Configure(config); Configured = true; } } } return(new Logger(className)); }
public Runner(INewRelicConfig config = null) { this.newRelicConfig = config ?? NewRelicConfig.Instance; _factories = new List <AgentFactory>(); _agents = new List <Agent>(); this.SetupProxy( this.newRelicConfig.ProxyHost, this.newRelicConfig.ProxyPort, this.newRelicConfig.ProxyUserName, this.newRelicConfig.ProxyPassword); // used for testing purposes _limit = this.newRelicConfig.NewRelicMaxIterations.GetValueOrDefault(); _limitRun = this.newRelicConfig.NewRelicMaxIterations.HasValue; }
public Runner(INewRelicConfig config = null) { this.newRelicConfig = config ?? NewRelicConfig.Instance; _factories = new List<AgentFactory>(); _agents = new List<Agent>(); this.SetupProxy( this.newRelicConfig.ProxyHost, this.newRelicConfig.ProxyPort, this.newRelicConfig.ProxyUserName, this.newRelicConfig.ProxyPassword); // used for testing purposes _limit = this.newRelicConfig.NewRelicMaxIterations.GetValueOrDefault(); _limitRun = this.newRelicConfig.NewRelicMaxIterations.HasValue; }
/// <summary> /// This class is responsible for maintaining metrics that have been reported as well as sending them to the New Relic /// service. Any Components that share a Request reference will have their data sent to the service in one request. /// </summary> /// <param name="config">The configuration that should be used.</param> public Context(INewRelicConfig config = null) : this(null, config) { }
// methods in this region should only be called directly by tests #region CalledByTests internal static Logger GetLogger(string className, INewRelicConfig config) { if (!Configured || config != null) { lock (ConfigureLock) { if (!Configured || config != null) { Configure(config); Configured = true; } } } return new Logger(className); }