How to give cloud logging permission?

66 Views Asked by At

Hi I am using cloud logging api for logging in gcp.

The error is

logging client: rpc error: code = PermissionDenied desc = Permission 'logging.logEntries.create' denied on resource (or it may not exist).
error details: name = ErrorInfo reason = IAM_PERMISSION_DENIED domain = iam.googleapis.com metadata = map[permission:logging.logEntries.create]

I don't know how to resolve this. But I don't know exactly which service account is responsible for it.

Below is the code for initializing client where the project ID is coming from a variable.

ctx = context.Background()

    logClient, err := logging.NewClient(ctx, projectID)

    if err != nil {
        log.Fatalf("Failed to create logging client: %v", err)
    }

    // Creates a logger for the specified log name.
    logger = logClient.Logger("my-log")

    firestoreClient, err = firestore.NewClientWithDatabase(ctx, projectID, "capstone")
    if err != nil {
        log.Fatalf("Failed to create firestore client: %v", err)

        logger.Log(logging.Entry{
            Payload:  "Failed to create Firestore client",
            Severity: logging.Error,
        })
    }

I have added the 'Logging admin' permission to a service account that I created mannually. But still it gave me the same error.

I was trying to use cloud logging. But its giving me the permission denial errors.

0

There are 0 best solutions below