Google.Cloud.Logging.V2:LogNameOneof

问题描述

我正在编写一个.Net Core实用程序,该实用程序基本上是一个包装程序,它将消息/日志推送到GCP Stackdriver。在Google.cloud网站上也有对代码的引用

代码如下:

using System;
// Imports the Google Cloud Logging client library
using Google.Cloud.Logging.V2;
using Google.Cloud.Logging.Type;
using System.Collections.Generic;
using Google.Api;

namespace GoogleCloudSamples
{
    public class QuickStart
    {
        public static void Main(string[] args)
        {
            // Your Google Cloud Platform project ID.
            string projectId = "YOUR-PROJECT-ID";

            // Instantiates a client.
            var client = LoggingServiceV2Client.Create();

            // Prepare new log entry.
            LogEntry logEntry = new LogEntry();
            string logId = "my-log";
            LogName logName = new LogName(projectId,logId);
            LogNameOneof logNametoWrite = LogNameOneof.From(logName);
            logEntry.LogName = logName.ToString();
            logEntry.Severity = LogSeverity.Info;
...

我的问题是与此行LogNameOneof logNametoWrite = LogNameOneof.From(logName);- LogNameOneof ,我遇到了一个错误,还有其他人能够做到这一点吗?

解决方法

我查看了在github上进行的最近更改,这些更改描述了此配置,并且看起来“ LogNameOneof logNameToWrite = LogNameOneof.From(logName);”已被替换为“ logEntry.LogNameAsLogName = logName;”。可以从最近在4月6日完成的cleanup中查看此更改。