# Stackdriver Logging API . entries

## Instance Methods

Lists log entries. Use this method to retrieve log entries from Cloud

Writes log entries to Stackdriver Logging. All log entries are

### 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`.
        "resourceNames": [ # Optional. One or more cloud resources from which to retrieve log entries.
            # Example: `"projects/my-project-1A"`, `"projects/1234567890"`.  Projects
            # listed in `projectIds` are added to this list.
          "A String",
        ],
        "pageSize": 42, # Optional. The maximum number of results to return from this request.
            # Non-positive values are ignored.  The presence of `nextPageToken` in the
            # response indicates that more results might be available.
        "filter": "A String", # Optional. A filter that chooses which log entries to return.  See [Advanced
            # Logs Filters](/logging/docs/view/advanced_filters).  Only log entries that
            # match the filter are returned.  An empty filter matches all log entries.
        "pageToken": "A String", # Optional. If present, then retrieve the next batch of results from the
            # preceding call to this method.  `pageToken` must be the value of
            # `nextPageToken` from the previous response.  The values of other method
            # parameters should be identical to those in the previous call.
        "projectIds": [ # Deprecated. One or more project identifiers or project numbers from which
            # to retrieve log entries.  Examples: `"my-project-1A"`, `"1234567890"`. If
            # present, these project identifiers are converted to resource format and
            # added to the list of resources in `resourceNames`. Callers should use
            # `resourceNames` rather than this parameter.
          "A String",
        ],
      }

      x__xgafv: string, V1 error format.
        Allowed values
          1 - v1 error format
          2 - v2 error format

    Returns:
      An object of the form:

        { # Result returned from `ListLogEntries`.
        "nextPageToken": "A String", # If there might be more results than appear in this response, then
            # `nextPageToken` is included.  To get the next set 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. Only contains semantics # Optional. Information about the HTTP request associated with this
                # log entry, if applicable.
                # defined by the HTTP specification. Product-specific logging
                # information MUST be defined in a separate message.
              "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.
              "requestMethod": "A String", # The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`, `"POST"`.
              "latency": "A String", # The request processing latency on the server, from the time the request was
                  # received until the response was sent.
              "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"`.
              "serverIp": "A String", # The IP address (IPv4 or IPv6) of the origin server that the request was
                  # sent to.
              "cacheLookup": True or False, # Whether or not a cache lookup was attempted.
              "cacheHit": True or False, # Whether or not an entity was served from cache
                  # (with or without validation).
              "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, # 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.
                # 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": "12345678901234",
                #                   "zone": "us-central1-a" }}
              "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, Stackdriver Logging will use the time the log entry is received.
            "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 project with the same ID as duplicates which can be removed.  If
                # omitted, Stackdriver 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/my-projectid/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.  Some
                # Google Cloud Platform services use this field for their log
                # entry payloads.
              "a_key": "", # Properties of the object. Contains field @type with type URL.
            },
            "operation": { # Additional information about a potentially long-running operation with which # Optional. Information about an operation associated with the log entry, if
                # applicable.
                # a log entry is associated.
              "last": True or False, # Optional. Set this to True if this is the last log entry in the operation.
              "id": "A String", # Optional. An arbitrary operation identifier. Log entries with the
                  # same identifier are assumed to be part of the same operation.
              "producer": "A String", # Optional. 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 Stackdriver Logging.  All log entries 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, # Optional. A default monitored resource object that is assigned to all log
            # entries in `entries` that do not specify a value for `resource`. Example:
            #
            #     { "type": "gce_instance",
            #       "labels": {
            #         "zone": "us-central1-a", "instance_id": "00000000000000000000" }}
            #
            # See LogEntry.
            # 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": "12345678901234",
            #                   "zone": "us-central1-a" }}
          "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. Default labels that are added to the `labels` field of all log
            # entries in `entries`. If a log entry already has a label with the same key
            # as a label in this parameter, then the log entry's label is not changed.
            # See LogEntry.
          "a_key": "A String",
        },
        "logName": "A String", # Optional. A default log resource name that is assigned to all log entries
            # in `entries` that do not specify a value for `log_name`.  Example:
            # `"projects/my-project/logs/syslog"`.  See
            # LogEntry.
        "entries": [ # Required. The log entries to write. Values supplied for the fields
            # `log_name`, `resource`, and `labels` in this `entries.write` request are
            # added to those log entries that do not provide their own values for the
            # fields.
            #
            # To improve throughput and to avoid exceeding the
            # [quota limit](/logging/quota-policy) for calls to `entries.write`,
            # you should write multiple log entries at once rather than
            # calling this method for each individual log entry.
          { # An individual entry in a log.
            "httpRequest": { # A common proto for logging HTTP requests. Only contains semantics # Optional. Information about the HTTP request associated with this
                # log entry, if applicable.
                # defined by the HTTP specification. Product-specific logging
                # information MUST be defined in a separate message.
              "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.
              "requestMethod": "A String", # The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`, `"POST"`.
              "latency": "A String", # The request processing latency on the server, from the time the request was
                  # received until the response was sent.
              "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"`.
              "serverIp": "A String", # The IP address (IPv4 or IPv6) of the origin server that the request was
                  # sent to.
              "cacheLookup": True or False, # Whether or not a cache lookup was attempted.
              "cacheHit": True or False, # Whether or not an entity was served from cache
                  # (with or without validation).
              "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, # 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.
                # 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": "12345678901234",
                #                   "zone": "us-central1-a" }}
              "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, Stackdriver Logging will use the time the log entry is received.
            "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 project with the same ID as duplicates which can be removed.  If
                # omitted, Stackdriver 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/my-projectid/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.  Some
                # Google Cloud Platform services use this field for their log
                # entry payloads.
              "a_key": "", # Properties of the object. Contains field @type with type URL.
            },
            "operation": { # Additional information about a potentially long-running operation with which # Optional. Information about an operation associated with the log entry, if
                # applicable.
                # a log entry is associated.
              "last": True or False, # Optional. Set this to True if this is the last log entry in the operation.
              "id": "A String", # Optional. An arbitrary operation identifier. Log entries with the
                  # same identifier are assumed to be part of the same operation.
              "producer": "A String", # Optional. 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.
        Allowed values
          1 - v1 error format
          2 - v2 error format

    Returns:
      An object of the form:

        { # Result returned from WriteLogEntries.
          # empty
      }