# Google Cloud Logging API . entries

## Instance Methods

Lists log entries. Use this method to retrieve log entries from Cloud Logging. For ways to export log entries, see [Exporting Logs](/logging/docs/export).

Writes log entries to Cloud Logging. All log entries in Cloud Logging are written by this method.

### Method Details

`list(body, x__xgafv=None)`

    Lists log entries. Use this method to retrieve log entries from Cloud Logging. For ways to export log entries, see [Exporting Logs](/logging/docs/export).

    Args:
      body: object, The request body. (required)
        The object takes the form of:

    { # The parameters to `ListLogEntries`.
        "filter": "A String", # Optional. An [advanced logs filter](/logging/docs/view/advanced_filters). The filter is compared against all log entries in the projects specified by `projectIds`. Only entries that match the filter are retrieved. An empty filter matches all log entries.
        "projectIds": [ # Required. One or more project IDs or project numbers from which to retrieve log entries. Examples of a project ID: `"my-project-1A"`, `"1234567890"`.
          "A String",
        ],
        "pageSize": 42, # Optional. The maximum number of results to return from this request. Fewer results might be returned. You must check for the `nextPageToken` result to determine if additional results are available, which you can retrieve by passing the `nextPageToken` value in the `pageToken` parameter to the next request.
        "orderBy": "A String", # Optional. How the results should be sorted. Presently, the only permitted values are `"timestamp"` (default) and `"timestamp desc"`. The first option returns entries in order of increasing values of `LogEntry.timestamp` (oldest first), and the second option returns entries in order of decreasing timestamps (newest first). Entries with equal timestamps are returned in order of `LogEntry.insertId`.
        "pageToken": "A String", # Optional. If the `pageToken` request parameter is supplied, then the next page of results in the set are retrieved. The `pageToken` parameter must be set with the value of the `nextPageToken` result parameter from the previous request. The values of `projectIds`, `filter`, and `orderBy` must be the same as in the previous request.
      }

      x__xgafv: string, V1 error format.

    Returns:
      An object of the form:

        { # Result returned from `ListLogEntries`.
        "nextPageToken": "A String", # If there are more results than were returned, then `nextPageToken` is given a value in the response. To get the next batch of results, call this method again using the value of `nextPageToken` as `pageToken`.
        "entries": [ # A list of log entries.
          { # An individual entry in a log.
            "httpRequest": { # A common proto for logging HTTP requests. # Optional. Information about the HTTP request associated with this log entry, if applicable.
              "status": 42, # The response code indicating the status of response. Examples: 200, 404.
              "cacheHit": True or False, # Whether or not an entity was served from cache (with or without validation).
              "requestUrl": "A String", # The scheme (http, https), the host name, the path and the query portion of the URL that was requested. Example: `"http://example.com/some/info?color=red"`.
              "requestMethod": "A String", # The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`, `"POST"`.
              "referer": "A String", # The referer URL of the request, as defined in [HTTP/1.1 Header Field Definitions](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
              "remoteIp": "A String", # The IP address (IPv4 or IPv6) of the client that issued the HTTP request. Examples: `"192.168.1.1"`, `"FE80::0202:B3FF:FE1E:8329"`.
              "validatedWithOriginServer": True or False, # Whether or not the response was validated with the origin server before being served from cache. This field is only meaningful if `cache_hit` is True.
              "userAgent": "A String", # The user agent sent by the client. Example: `"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET CLR 1.0.3705)"`.
              "requestSize": "A String", # The size of the HTTP request message in bytes, including the request headers and the request body.
              "responseSize": "A String", # The size of the HTTP response message sent back to the client, in bytes, including the response headers and the response body.
            },
            "resource": { # A specific monitored resource or a group of monitored resources. # Required. The monitored resource associated with this log entry. Example: a log entry that reports a database error would be associated with the monitored resource designating the particular database that reported the error.
              "labels": { # Values for some or all of the labels listed in the associated monitored resource descriptor. For example, specify a specific Cloud SQL database by supplying values for both the `"database_id"` and `"zone"` labels. Specify the set of all Cloud SQL databases in a particular location by supplying a value for only the `"zone"` label.
                "a_key": "A String",
              },
              "type": "A String", # The type of monitored resource. This field must match the value of the `type` field in a MonitoredResourceDescriptor object. For example, `"cloudsql_database"` represents Cloud SQL databases.
            },
            "severity": "A String", # Optional. The severity of the log entry. The default value is `LogSeverity.DEFAULT`.
            "textPayload": "A String", # The log entry payload, represented as a Unicode string (UTF-8).
            "timestamp": "A String", # Optional. The time the event described by the log entry occurred. If omitted, Cloud Logging will use the time the log entry is written.
            "labels": { # Optional. A set of user-defined (key, value) data that provides additional information about the log entry.
              "a_key": "A String",
            },
            "insertId": "A String", # Optional. 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. If omitted, Cloud Logging will generate a unique ID for this log entry.
            "jsonPayload": { # The log entry payload, represented as a structure that is expressed as a JSON object.
              "a_key": "", # Properties of the object.
            },
            "logName": "A String", # Required. The resource name of the log to which this log entry belongs. The format of the name is `projects//logs/

`write(body, x__xgafv=None)`

    Writes log entries to Cloud Logging. All log entries in Cloud Logging are written by this method.

    Args:
      body: object, The request body. (required)
        The object takes the form of:

    { # The parameters to WriteLogEntries.
        "resource": { # A specific monitored resource or a group of monitored resources. # Optional. A default monitored resource for those log entries in `entries` that do not specify their own `resource`.
          "labels": { # Values for some or all of the labels listed in the associated monitored resource descriptor. For example, specify a specific Cloud SQL database by supplying values for both the `"database_id"` and `"zone"` labels. Specify the set of all Cloud SQL databases in a particular location by supplying a value for only the `"zone"` label.
            "a_key": "A String",
          },
          "type": "A String", # The type of monitored resource. This field must match the value of the `type` field in a MonitoredResourceDescriptor object. For example, `"cloudsql_database"` represents Cloud SQL databases.
        },
        "labels": { # Optional. User-defined `key:value` items that are added to the `labels` field of each log entry in `entries`, except when a log entry specifies its own `key:value` item with the same key. Example: `{ "size": "large", "color":"red" }`
          "a_key": "A String",
        },
        "logName": "A String", # Optional. A default log resource name for those log entries in `entries` that do not specify their own `logName`. Example: `"projects/my-project/logs/syslog"`. See LogEntry.
        "entries": [ # Required. The log entries to write. The log entries must have values for all required fields.
          { # An individual entry in a log.
            "httpRequest": { # A common proto for logging HTTP requests. # Optional. Information about the HTTP request associated with this log entry, if applicable.
              "status": 42, # The response code indicating the status of response. Examples: 200, 404.
              "cacheHit": True or False, # Whether or not an entity was served from cache (with or without validation).
              "requestUrl": "A String", # The scheme (http, https), the host name, the path and the query portion of the URL that was requested. Example: `"http://example.com/some/info?color=red"`.
              "requestMethod": "A String", # The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`, `"POST"`.
              "referer": "A String", # The referer URL of the request, as defined in [HTTP/1.1 Header Field Definitions](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
              "remoteIp": "A String", # The IP address (IPv4 or IPv6) of the client that issued the HTTP request. Examples: `"192.168.1.1"`, `"FE80::0202:B3FF:FE1E:8329"`.
              "validatedWithOriginServer": True or False, # Whether or not the response was validated with the origin server before being served from cache. This field is only meaningful if `cache_hit` is True.
              "userAgent": "A String", # The user agent sent by the client. Example: `"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET CLR 1.0.3705)"`.
              "requestSize": "A String", # The size of the HTTP request message in bytes, including the request headers and the request body.
              "responseSize": "A String", # The size of the HTTP response message sent back to the client, in bytes, including the response headers and the response body.
            },
            "resource": { # A specific monitored resource or a group of monitored resources. # Required. The monitored resource associated with this log entry. Example: a log entry that reports a database error would be associated with the monitored resource designating the particular database that reported the error.
              "labels": { # Values for some or all of the labels listed in the associated monitored resource descriptor. For example, specify a specific Cloud SQL database by supplying values for both the `"database_id"` and `"zone"` labels. Specify the set of all Cloud SQL databases in a particular location by supplying a value for only the `"zone"` label.
                "a_key": "A String",
              },
              "type": "A String", # The type of monitored resource. This field must match the value of the `type` field in a MonitoredResourceDescriptor object. For example, `"cloudsql_database"` represents Cloud SQL databases.
            },
            "severity": "A String", # Optional. The severity of the log entry. The default value is `LogSeverity.DEFAULT`.
            "textPayload": "A String", # The log entry payload, represented as a Unicode string (UTF-8).
            "timestamp": "A String", # Optional. The time the event described by the log entry occurred. If omitted, Cloud Logging will use the time the log entry is written.
            "labels": { # Optional. A set of user-defined (key, value) data that provides additional information about the log entry.
              "a_key": "A String",
            },
            "insertId": "A String", # Optional. 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. If omitted, Cloud Logging will generate a unique ID for this log entry.
            "jsonPayload": { # The log entry payload, represented as a structure that is expressed as a JSON object.
              "a_key": "", # Properties of the object.
            },
            "logName": "A String", # Required. The resource name of the log to which this log entry belongs. The format of the name is `projects//logs/