# 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`.
        "orderBy": "A String", # Optional. How the results should be sorted. Presently, the only permitted values are `"timestamp asc"` (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`.
        "pageSize": 42, # Optional. The maximum number of results to return from this request. You must check for presence of `nextPageToken` to determine if additional results are available, which you can retrieve by passing the `nextPageToken` value as the `pageToken` parameter in the next request.
        "partialSuccess": True or False, # Optional. If true, read access to all projects is not required and results will be returned for the subset of projects for which read access is permitted (empty subset is permitted).
        "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.
        "pageToken": "A String", # Optional. If the `pageToken` parameter is supplied, then the next page of results is retrieved. The `pageToken` parameter must be set to the value of the `nextPageToken` from the previous response. The values of `projectIds`, `filter`, and `orderBy` must be the same as in the previous request.
        "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",
        ],
      }

      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 included in the response. To get the next set of results, call this method again using the value of `nextPageToken` as `pageToken`.
        "projectIdErrors": { # If partial_success is true, contains the project ids that had errors and the associated errors.
          "a_key": { # The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). The error model is designed to be: - Simple to use and understand for most users - Flexible enough to meet unexpected needs # Overview The `Status` message contains three pieces of data: error code, error message, and error details. The error code should be an enum value of google.rpc.Code, but it may accept additional error codes if needed. The error message should be a developer-facing English message that helps developers *understand* and *resolve* the error. If a localized user-facing error message is needed, put the localized message in the error details or localize it in the client. The optional error details may contain arbitrary information about the error. There is a predefined set of error detail types in the package `google.rpc` which can be used for common error conditions. # Language mapping The `Status` message is the logical representation of the error model, but it is not necessarily the actual wire format. When the `Status` message is exposed in different client libraries and different wire protocols, it can be mapped differently. For example, it will likely be mapped to some exceptions in Java, but more likely mapped to some error codes in C. # Other uses The error model and the `Status` message can be used in a variety of environments, either with or without APIs, to provide a consistent developer experience across different environments. Example uses of this error model include: - Partial errors. If a service needs to return partial errors to the client, it may embed the `Status` in the normal response to indicate the partial errors. - Workflow errors. A typical workflow has multiple steps. Each step may have a `Status` message for error reporting purpose. - Batch operations. If a client uses batch request and batch response, the `Status` message should be used directly inside batch response, one for each error sub-response. - Asynchronous operations. If an API call embeds asynchronous operation results in its response, the status of those operations should be represented directly using the `Status` message. - Logging. If some API errors are stored in logs, the message `Status` could be used directly after any stripping needed for security/privacy reasons.
            "message": "A String", # A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
            "code": 42, # The status code, which should be an enum value of google.rpc.Code.
            "details": [ # A list of messages that carry the error details. There will be a common set of message types for APIs to use.
              {
                "a_key": "", # Properties of the object. Contains field @ype with type URL.
              },
            ],
          },
        },
        "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.
              "cacheValidatedWithOriginServer": 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.
              "cacheHit": True or False, # Whether or not an entity was served from cache (with or without validation).
              "cacheFillBytes": "A String", # The number of HTTP response bytes inserted into cache. Set only when a cache fill was attempted.
              "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"`.
              "cacheLookup": True or False, # Whether or not a cache lookup was attempted.
              "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"`.
              "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": { # An object representing a resource that can be used for monitoring, logging, billing, or other purposes. Examples include virtual machine instances, databases, and storage devices such as disks. The `type` field identifies a MonitoredResourceDescriptor object that describes the resource's schema. Information in the `labels` field identifies the actual resource and its attributes according to the schema. For example, a particular Compute Engine VM instance could be represented by the following object, because the MonitoredResourceDescriptor for `"gce_instance"` has labels `"instance_id"` and `"zone"`: { "type": "gce_instance", "labels": { "instance_id": "my-instance", "zone": "us-central1-a" }} # 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": { # Required. Values for all of the labels listed in the associated monitored resource descriptor. For example, Cloud SQL databases use the labels `"database_id"` and `"zone"`.
                "a_key": "A String",
              },
              "type": "A String", # Required. The monitored resource type. This field must match the `type` field of a MonitoredResourceDescriptor object. For example, the type of a Cloud SQL database is `"cloudsql_database"`.
            },
            "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/"`. Examples: `"projects/my-projectid/logs/syslog"`, `"projects/1234567890/logs/library.googleapis.com%2Fbook_log"`. The log ID part of resource name must be less than 512 characters long and can only include the following characters: upper and lower case alphanumeric characters: [A-Za-z0-9]; and punctuation characters: forward-slash, underscore, hyphen, and period. Forward-slash (`/`) characters in the log ID must be URL-encoded.
            "protoPayload": { # The log entry payload, represented as a protocol buffer. You can only use `protoPayload` values that belong to a set of approved types.
              "a_key": "", # Properties of the object. Contains field @ype with type URL.
            },
            "operation": { # Additional information about a potentially long-running operation with which a log entry is associated. # Optional. Information about an operation associated with the log entry, if applicable.
              "last": True or False, # Optional. Set this to True if this is the last log entry in the operation.
              "id": "A String", # Required. An arbitrary operation identifier. Log entries with the same identifier are assumed to be part of the same operation.
              "producer": "A String", # Required. An arbitrary producer identifier. The combination of `id` and `producer` must be globally unique. Examples for `producer`: `"MyDivision.MyBigCompany.com"`, "github.com/MyProject/MyApplication"`.
              "first": True or False, # Optional. Set this to True if this is the first log entry in the operation.
            },
          },
        ],
      }

`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": { # An object representing a resource that can be used for monitoring, logging, billing, or other purposes. Examples include virtual machine instances, databases, and storage devices such as disks. The `type` field identifies a MonitoredResourceDescriptor object that describes the resource's schema. Information in the `labels` field identifies the actual resource and its attributes according to the schema. For example, a particular Compute Engine VM instance could be represented by the following object, because the MonitoredResourceDescriptor for `"gce_instance"` has labels `"instance_id"` and `"zone"`: { "type": "gce_instance", "labels": { "instance_id": "my-instance", "zone": "us-central1-a" }} # Optional. A default monitored resource for those log entries in `entries` that do not specify their own `resource`.
          "labels": { # Required. Values for all of the labels listed in the associated monitored resource descriptor. For example, Cloud SQL databases use the labels `"database_id"` and `"zone"`.
            "a_key": "A String",
          },
          "type": "A String", # Required. The monitored resource type. This field must match the `type` field of a MonitoredResourceDescriptor object. For example, the type of a Cloud SQL database is `"cloudsql_database"`.
        },
        "partialSuccess": True or False, # Optional. Whether valid entries should be written even if some other entries fail due to INVALID_ARGUMENT or PERMISSION_DENIED errors. If any entry is not written, the response status will be the error associated with one of the failed entries and include error details in the form of WriteLogEntriesPartialErrors.
        "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.
              "cacheValidatedWithOriginServer": 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.
              "cacheHit": True or False, # Whether or not an entity was served from cache (with or without validation).
              "cacheFillBytes": "A String", # The number of HTTP response bytes inserted into cache. Set only when a cache fill was attempted.
              "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"`.
              "cacheLookup": True or False, # Whether or not a cache lookup was attempted.
              "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"`.
              "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": { # An object representing a resource that can be used for monitoring, logging, billing, or other purposes. Examples include virtual machine instances, databases, and storage devices such as disks. The `type` field identifies a MonitoredResourceDescriptor object that describes the resource's schema. Information in the `labels` field identifies the actual resource and its attributes according to the schema. For example, a particular Compute Engine VM instance could be represented by the following object, because the MonitoredResourceDescriptor for `"gce_instance"` has labels `"instance_id"` and `"zone"`: { "type": "gce_instance", "labels": { "instance_id": "my-instance", "zone": "us-central1-a" }} # 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": { # Required. Values for all of the labels listed in the associated monitored resource descriptor. For example, Cloud SQL databases use the labels `"database_id"` and `"zone"`.
                "a_key": "A String",
              },
              "type": "A String", # Required. The monitored resource type. This field must match the `type` field of a MonitoredResourceDescriptor object. For example, the type of a Cloud SQL database is `"cloudsql_database"`.
            },
            "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/"`. Examples: `"projects/my-projectid/logs/syslog"`, `"projects/1234567890/logs/library.googleapis.com%2Fbook_log"`. The log ID part of resource name must be less than 512 characters long and can only include the following characters: upper and lower case alphanumeric characters: [A-Za-z0-9]; and punctuation characters: forward-slash, underscore, hyphen, and period. Forward-slash (`/`) characters in the log ID must be URL-encoded.
            "protoPayload": { # The log entry payload, represented as a protocol buffer. You can only use `protoPayload` values that belong to a set of approved types.
              "a_key": "", # Properties of the object. Contains field @ype with type URL.
            },
            "operation": { # Additional information about a potentially long-running operation with which a log entry is associated. # Optional. Information about an operation associated with the log entry, if applicable.
              "last": True or False, # Optional. Set this to True if this is the last log entry in the operation.
              "id": "A String", # Required. An arbitrary operation identifier. Log entries with the same identifier are assumed to be part of the same operation.
              "producer": "A String", # Required. An arbitrary producer identifier. The combination of `id` and `producer` must be globally unique. Examples for `producer`: `"MyDivision.MyBigCompany.com"`, "github.com/MyProject/MyApplication"`.
              "first": True or False, # Optional. Set this to True if this is the first log entry in the operation.
            },
          },
        ],
      }

      x__xgafv: string, V1 error format.

    Returns:
      An object of the form:

        { # Result returned from WriteLogEntries. empty
      }