I am writing a .Net Core utility that is basically a wrapper that will push messages/logs to GCP Stackdriver. There is also a reference to the code on the Google.cloud site
Here is the code:
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;
...
My question is with this line LogNameOneof logNameToWrite = LogNameOneof.From(logName);
- I get an error with, LogNameOneof, has anyone else been able to make this work?
I reviewed the recent changes that were made on github that portrays this configuration and it appears that “LogNameOneof logNameToWrite = LogNameOneof.From(logName);” has been replaced by “ logEntry.LogNameAsLogName = logName;”. This change can be viewed from the recent cleanup that was done on April 6th.