コード例 #1
0
        /// <summary>
        /// Setup DataDog
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public LoggerBuilder SetupDataDog(DataDogOptions options)
        {
            this.OutputConfiguration.DataDog.Options = options
                                                       ?? throw new ArgumentNullException(nameof(options));

            if (string.IsNullOrWhiteSpace(options.ApiKey) == true && options.Enabled == true)
            {
                throw new ArgumentNullException(nameof(options.ApiKey));
            }

            this.OutputConfiguration.DataDog.Enabled = options.Enabled;

            return(this);
        }
コード例 #2
0
        public static void Build_Basics_Logger()
        {
            // arrage
            LoggerBuilder builder = new LoggerBuilder();

            SeqOptions seqOptions = new SeqOptions
            {
                Url    = "http://localhost",
                ApiKey = "123456"
            };

            SplunkOptions splunkOptions = new SplunkOptions
            {
                Url   = "http://localhost",
                Token = "123456",
                Index = "my.index"
            };

            NewRelicOptions newRelicOptions = new NewRelicOptions
            {
                AppName    = "asd",
                LicenseKey = "123"
            };

            DataDogOptions dataDogOptions = new DataDogOptions
            {
                ApiKey  = "123",
                Service = "service",
                Host    = "host",
                Tags    = new string[] { "tags" },
                Source  = "source"
            };

            Log.Logger = builder
                         .UseSuggestedSetting("MyDomain", "MyApplication")
                         .SetupSeq(seqOptions)
                         .SetupSplunk(splunkOptions)
                         .SetupNewRelic(newRelicOptions)
                         .SetupDataDog(dataDogOptions)
                         .BuildLogger();

            // act
            var logger = builder.BuildLogger();

            // assert
            Assert.NotNull(logger);
        }