# Google Cloud Logging API . projects . logs . entries

## Instance Methods

Writes log entries to Cloud Logging. Each entry consists of a `LogEntry` object. You must fill in all the fields of the object, including one of the payload fields. You may supply a map, `commonLabels`, that holds default (key, value) data for the `entries[].metadata.labels` map in each entry, saving you the trouble of creating identical copies for each entry.

### Method Details

`write(projectsId, logsId, body, x__xgafv=None)`

    Writes log entries to Cloud Logging. Each entry consists of a `LogEntry` object. You must fill in all the fields of the object, including one of the payload fields. You may supply a map, `commonLabels`, that holds default (key, value) data for the `entries[].metadata.labels` map in each entry, saving you the trouble of creating identical copies for each entry.

    Args:
      projectsId: string, Part of `logName`. The resource name of the log that will receive the log entries. (required)
      logsId: string, Part of `logName`. See documentation of `projectsId`. (required)
      body: object, The request body. (required)
        The object takes the form of:

    { # The parameters to WriteLogEntries.
        "commonLabels": { # Metadata labels that apply to all log entries in this request, so that you don't have to repeat them in each log entry's `metadata.labels` field. If any of the log entries contains a (key, value) with the same key that is in `commonLabels`, then the entry's (key, value) overrides the one in `commonLabels`.
          "a_key": "A String",
        },
        "entries": [ # Log entries to insert.
          { # An individual entry in a log.
            "httpRequest": { # A common proto for logging HTTP requests. # Information about the HTTP request associated with this log entry, if applicable.
              "status": 42, # A response code indicates the status of response, e.g., 200.
              "requestUrl": "A String", # Contains the scheme (http|https), the host name, the path and the query portion of the URL that was requested.
              "requestMethod": "A String", # Request method, such as `GET`, `HEAD`, `PUT` or `POST`.
              "referer": "A String", # Referer (a.k.a. referrer) URL of request, as defined in http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html.
              "remoteIp": "A String", # IP address of the client who issues the HTTP request. Could be either IPv4 or IPv6.
              "userAgent": "A String", # User agent sent by the client, e.g., "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET CLR 1.0.3705)".
              "requestSize": "A String", # Size of the HTTP request message in bytes, including request headers and the request body.
              "responseSize": "A String", # Size of the HTTP response message in bytes sent back to the client, including response headers and response body.
            },
            "log": "A String", # The log to which this entry belongs. When a log entry is ingested, the value of this field is set by the logging system.
            "textPayload": "A String", # The log entry payload, represented as a text string.
            "structPayload": { # The log entry payload, represented as a structure that is expressed as a JSON object.
              "a_key": "", # Properties of the object.
            },
            "insertId": "A String", # A unique ID for the log entry. If you provide this field, the logging service considers other log entries in the same log with the same ID as duplicates which can be removed.
            "protoPayload": { # The log entry payload, represented as a protocol buffer that is expressed as a JSON object. You can only pass `protoPayload` values that belong to a set of approved types.
              "a_key": "", # Properties of the object. Contains field @ype with type URL.
            },
            "metadata": { # Additional data that is associated with a log entry, set by the service creating the log entry. # Information about the log entry.
              "severity": "A String", # The severity of the log entry.
              "zone": "A String", # The zone of the Google Cloud Platform service that created the log entry. For example, `"us-central1-a"`.
              "timestamp": "A String", # The time the event described by the log entry occurred. Timestamps must be later than January 1, 1970.
              "region": "A String", # The region name of the Google Cloud Platform service that created the log entry. For example, `"us-central1"`.
              "labels": { # A set of (key, value) data that provides additional information about the log entry. If the log entry is from one of the Google Cloud Platform sources listed below, the indicated (key, value) information must be provided: Google App Engine, service_name `appengine.googleapis.com`: "appengine.googleapis.com/module_id",  "appengine.googleapis.com/version_id",  and one of: "appengine.googleapis.com/replica_index",  "appengine.googleapis.com/clone_id",  or else provide the following Compute Engine labels: Google Compute Engine, service_name `compute.googleapis.com`: "compute.googleapis.com/resource_type", "instance" "compute.googleapis.com/resource_id",
                "a_key": "A String",
              },
              "userId": "A String", # The fully-qualified email address of the authenticated user that performed or requested the action represented by the log entry. If the log entry does not apply to an action taken by an authenticated user, then the field should be empty.
              "serviceName": "A String", # The API name of the Google Cloud Platform service that created the log entry. For example, `"compute.googleapis.com"`.
              "projectId": "A String", # The project ID of the Google Cloud Platform service that created the log entry.
            },
          },
        ],
      }

      x__xgafv: string, V1 error format.

    Returns:
      An object of the form:

        { # Result returned from WriteLogEntries. empty
      }