Example #1
0
        // TODO
        // Check correctness of _logNameToWrite variable, because there were some changes in google API
        // and this variable was changed to build project successfully.
        public GoogleCloudLoggingSink(GoogleCloudLoggingSinkOptions sinkOptions, MessageTemplateTextFormatter messageTemplateTextFormatter, int batchSizeLimit, TimeSpan period)
            : base(batchSizeLimit, period)
        {
            _client      = LoggingServiceV2Client.Create();
            _sinkOptions = sinkOptions;

            _resource = new MonitoredResource {
                Type = sinkOptions.ResourceType
            };

            var ln = new LogName(sinkOptions.ProjectId, sinkOptions.LogName);

            _logName        = ln.ToString();
            _logNameToWrite = sinkOptions.LogName;

            _messageTemplateTextFormatter = messageTemplateTextFormatter;
        }
Example #2
0
        public LoggerConfiguration AddExtension(LoggerConfiguration config)
        {
            var options = new GoogleCloudLoggingSinkOptions(_cloudSettings.ProjectId, logName: _cloudSettings.ApplicationName);

            return(config.WriteTo.GoogleCloudLogging(options));
        }
        public static LoggerConfiguration GoogleCloudLogging(this LoggerSinkConfiguration loggerConfiguration, GoogleCloudLoggingSinkOptions sinkOptions, int?batchSizeLimit = null, TimeSpan?period = null, string outputTemplate = null)
        {
            var messageTemplateTextFormatter = string.IsNullOrWhiteSpace(outputTemplate) ? null : new MessageTemplateTextFormatter(outputTemplate, null);

            var sink = new GoogleCloudLoggingSink(
                sinkOptions,
                messageTemplateTextFormatter,
                batchSizeLimit ?? 100,
                period ?? TimeSpan.FromSeconds(5));

            return(loggerConfiguration.Sink(sink));
        }