LogEntry

An individual entry in a log.

JSON representation
{
  "logName": string,
  "resource": {
    object(MonitoredResource)
  },
  "timestamp": string,
  "receiveTimestamp": string,
  "severity": enum(LogSeverity),
  "insertId": string,
  "httpRequest": {
    object(HttpRequest)
  },
  "labels": {
    string: string,
    ...
  },
  "operation": {
    object(LogEntryOperation)
  },
  "trace": string,
  "spanId": string,
  "sourceLocation": {
    object(LogEntrySourceLocation)
  },

  // Union field payload can be only one of the following:
  "protoPayload": {
    "@type": string,
    field1: ...,
    ...
  },
  "textPayload": string,
  "jsonPayload": {
    object
  },
  // End of list of possible types for union field payload.
}
Fields
logName

string

Required. The resource name of the log to which this log entry belongs:

"projects/[PROJECT_ID]/logs/[LOG_ID]"
"organizations/[ORGANIZATION_ID]/logs/[LOG_ID]"
"billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]"
"folders/[FOLDER_ID]/logs/[LOG_ID]"

A project number may optionally be used in place of PROJECT_ID. The project number is translated to its corresponding PROJECT_ID internally and the logName field will contain PROJECT_ID in queries and exports.

[LOG_ID] must be URL-encoded within logName. Example: "organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity". [LOG_ID] must be less than 512 characters long and can only include the following characters: upper and lower case alphanumeric characters, forward-slash, underscore, hyphen, and period.

For backward compatibility, if logName begins with a forward-slash, such as /projects/..., then the log entry is ingested as usual but the forward-slash is removed. Listing the log entry will not show the leading slash and filtering for a log name with a leading slash will never return any results.

resource

object(MonitoredResource)

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.

timestamp

string (Timestamp format)

Optional. The time the event described by the log entry occurred. This time is used to compute the log entry's age and to enforce the logs retention period. If this field is omitted in a new log entry, then Stackdriver Logging assigns it the current time.

Incoming log entries should have timestamps that are no more than the logs retention period in the past, and no more than 24 hours in the future. See the entries.write API method for more information.

A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".

receiveTimestamp

string (Timestamp format)

Output only. The time the log entry was received by Stackdriver Logging.

A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".

severity

enum(LogSeverity)

Optional. The severity of the log entry. The default value is LogSeverity.DEFAULT.

insertId

string

Optional. A unique identifier for the log entry. If you provide a value, then Stackdriver Logging considers other log entries in the same project, with the same timestamp, and with the same insertId to be duplicates which can be removed. If omitted in new log entries, then Stackdriver Logging assigns its own unique identifier. The insertId is also used to order log entries that have the same timestamp value.

httpRequest

object(HttpRequest)

Optional. Information about the HTTP request associated with this log entry, if applicable.

labels

map (key: string, value: string)

Optional. A set of user-defined (key, value) data that provides additional information about the log entry.

An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.

operation

object(LogEntryOperation)

Optional. Information about an operation associated with the log entry, if applicable.

trace

string

Optional. Resource name of the trace associated with the log entry, if any. If it contains a relative resource name, the name is assumed to be relative to //tracing.googleapis.com. Example: projects/my-projectid/traces/06796866738c859f2f19b7cfb3214824

spanId

string

Optional. The span ID within the trace associated with the log entry. For Stackdriver Trace spans, this is the same format that the Stackdriver Trace API uses: a 16-character hexadecimal encoding of an 8-byte array, such as "000000000000004a".

sourceLocation

object(LogEntrySourceLocation)

Optional. Source code location information associated with the log entry, if any.

Union field payload. Optional. The log entry payload, which can be one of multiple types. payload can be only one of the following:
protoPayload

object

The log entry payload, represented as a protocol buffer. Some Google Cloud Platform services use this field for their log entry payloads.

An object containing fields of an arbitrary type. An additional field "@type" contains a URI identifying the type. Example: { "id": 1234, "@type": "types.example.com/standard/id" }.

textPayload

string

The log entry payload, represented as a Unicode string (UTF-8).

jsonPayload

object (Struct format)

The log entry payload, represented as a structure that is expressed as a JSON object.

LogSeverity

The severity of the event described in a log entry, expressed as one of the standard severity levels listed below. For your reference, the levels are assigned the listed numeric values. The effect of using numeric values other than those listed is undefined.

You can filter for log entries by severity. For example, the following filter expression will match log entries with severities INFO, NOTICE, and WARNING:

severity > DEBUG AND severity <= WARNING

If you are writing log entries, you should map other severity encodings to one of these standard levels. For example, you might map all of Java's FINE, FINER, and FINEST levels to LogSeverity.DEBUG. You can preserve the original severity level in the log entry payload if you wish.

Enums
DEFAULT (0) The log entry has no assigned severity level.
DEBUG (100) Debug or trace information.
INFO (200) Routine information, such as ongoing status or performance.
NOTICE (300) Normal but significant events, such as start up, shut down, or a configuration change.
WARNING (400) Warning events might cause problems.
ERROR (500) Error events are likely to cause problems.
CRITICAL (600) Critical events cause more severe problems or outages.
ALERT (700) A person must take an action immediately.
EMERGENCY (800) One or more systems are unusable.

HttpRequest

A common proto for logging HTTP requests. Only contains semantics defined by the HTTP specification. Product-specific logging information MUST be defined in a separate message.

JSON representation
{
  "requestMethod": string,
  "requestUrl": string,
  "requestSize": string,
  "status": number,
  "responseSize": string,
  "userAgent": string,
  "remoteIp": string,
  "serverIp": string,
  "referer": string,
  "latency": string,
  "cacheLookup": boolean,
  "cacheHit": boolean,
  "cacheValidatedWithOriginServer": boolean,
  "cacheFillBytes": string,
  "protocol": string,
}
Fields
requestMethod

string

The request method. Examples: "GET", "HEAD", "PUT", "POST".

requestUrl

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".

requestSize

string (int64 format)

The size of the HTTP request message in bytes, including the request headers and the request body.

status

number

The response code indicating the status of response. Examples: 200, 404.

responseSize

string (int64 format)

The size of the HTTP response message sent back to the client, in bytes, including the response headers and the response body.

userAgent

string

The user agent sent by the client. Example: "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET CLR 1.0.3705)".

remoteIp

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".

serverIp

string

The IP address (IPv4 or IPv6) of the origin server that the request was sent to.

referer

string

The referer URL of the request, as defined in HTTP/1.1 Header Field Definitions.

latency

string (Duration format)

The request processing latency on the server, from the time the request was received until the response was sent.

A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".

cacheLookup

boolean

Whether or not a cache lookup was attempted.

cacheHit

boolean

Whether or not an entity was served from cache (with or without validation).

cacheValidatedWithOriginServer

boolean

Whether or not the response was validated with the origin server before being served from cache. This field is only meaningful if cacheHit is True.

cacheFillBytes

string (int64 format)

The number of HTTP response bytes inserted into cache. Set only when a cache fill was attempted.

protocol

string

Protocol used for the request. Examples: "HTTP/1.1", "HTTP/2", "websocket"

LogEntryOperation

Additional information about a potentially long-running operation with which a log entry is associated.

JSON representation
{
  "id": string,
  "producer": string,
  "first": boolean,
  "last": boolean,
}
Fields
id

string

Optional. An arbitrary operation identifier. Log entries with the same identifier are assumed to be part of the same operation.

producer

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

boolean

Optional. Set this to True if this is the first log entry in the operation.

last

boolean

Optional. Set this to True if this is the last log entry in the operation.

LogEntrySourceLocation

Additional information about the source code location that produced the log entry.

JSON representation
{
  "file": string,
  "line": string,
  "function": string,
}
Fields
file

string

Optional. Source file name. Depending on the runtime environment, this might be a simple name or a fully-qualified name.

line

string (int64 format)

Optional. Line within the source file. 1-based; 0 indicates no line number available.

function

string

Optional. Human-readable name of the function or method being invoked, with optional context such as the class or package name. This information may be used in contexts such as the logs viewer, where a file and line number are less meaningful. The format can vary by language. For example: qual.if.ied.Class.method (Java), dir/package.func (Go), function (Python).

Send feedback about...

Stackdriver Logging