예제 #1
0
        protected override void InitializeTarget()
        {
            base.InitializeTarget();

            var regionConfig = WebConfigurationManager.AppSettings["AWSRegion"] ?? "us-west-1";
            var region       = RegionEndpoint.GetBySystemName(regionConfig);

            try
            {
                var awsClient = new AmazonCloudWatchLogsClient(region);
                var logstream = !string.IsNullOrEmpty(Suffix)
                    ? string.Format("{0}-{1}-{2}", LogStreaam, Environment, Suffix)
                    : !string.IsNullOrEmpty(EC2InstanceMetadata.InstanceId)
                            ? string.Format("{0}-{1}-{2}", LogStreaam, Environment, EC2InstanceMetadata.InstanceId)
                            : string.Format("{0}-{1}", LogStreaam, Environment);

                InternalLogger.Debug("Writing LogStream", logstream);

                _client = new CloudWatchLogsClientWrapper(awsClient, LogGroup, logstream);
                _client.InitialiseLogStream();
            }
            catch (AmazonServiceException ex)
            {
                //purely for runnning it locally for the reason this will be still instantiated even if it's not part of the targe
                if (ex.Message != "Unable to find credentials")
                {
                    throw;
                }
            }
        }
예제 #2
0
 public void Setup(ICloudWatchLogsClientWrapper client)
 {
     _client = client;
 }