Package com.google.appengine.api.log (2.0.0)

Provides access to request logs and application logs. See Also: com.google.appengine.api.log.LogService

Classes

AppLogLine

An AppLogLine contains all the information for a single application log. Specifically, this information is: (1) the time at which the logged event occurred, (2) the level that the event was logged at, and (3) the message associated with this event. AppLogLines may be inserted by the user via logging frameworks, or by App Engine itself if we wish to alert the user that certain events have occurred.

ILogServiceFactoryProvider

Factory provider for ILogServiceFactory.

Note: This class is not intended for end users.

LogQuery

Allows users to customize the behavior of LogService#fetch(LogQuery).

startTime is the earliest request completion or last-update time that results should be fetched for, in seconds since the Unix epoch. If null then no requests will be excluded for ending too long ago.

endTime is the latest request completion or last-update time that results should be fetched for, in seconds since the Unix epoch. If null then no requests will be excluded for ending too recently.

offset is a cursor into the log stream retrieved from a previously emitted RequestLogs#getOffset. This iterator will begin returning logs immediately after the record from which the offset came. If null, the query will begin at startTime.

minLogLevel is a LogService.LogLevel which serves as a filter on the requests returned. Requests with no application logs at or above the specified level will be omitted. Works even if includeAppLogs is not True.

includeIncomplete selects whether requests that have started but not yet finished should be included in the query. Defaults to False.

includeAppLogs specifies whether or not to include application logs in the query results. Defaults to False.

majorVersionIds specifies versions of the application's default module for which logs records should retrieved.

versions specifies module versions of the application for which logs should be retrieved.

requestIds, if not empty(), indicates that instead of a time-based scan, logs for the specified requests should be returned. See the Request IDs section of the Java Servlet Environment documentation for how to retrieve these IDs at runtime. Malformed request IDs cause an exception and unrecognized request IDs are ignored. This option may not be combined with other filtering options such as startTime, endTime, offset, or minLogLevel. When requestIds is not empty(), majorVersionIds are ignored. Logs are returned in the order requested.

batchSize specifies the internal batching strategy of the returned Iterable < RequestLogs >. Has no impact on the result of the query.

Notes on usage:
The recommended way to instantiate a LogQuery object is to statically import Builder.* and invoke a static creation method followed by an instance mutator (if needed):


 import static com.google.appengine.api.log.LogQuery.Builder.*;

 ...

 // All requests, including application logs.
 iter = logService.fetch(withIncludeAppLogs(true));

 // All requests ending in the past day (or still running) with an info log or higher.
 Calendar cal = Calendar.getInstance();
 cal.add(Calendar.DAY_OF_MONTH, -1);
 iter = logService.fetch(withEndTimeMillis(cal.time())
     .includeIncomplete(true).minimumLogLevel(LogService.INFO));
 

There are a couple of ways to configure LogQuery to limit LogService#fetch(LogQuery) to only return log records for specific module versions.

  1. #versions(List)(Builder#withVersions(List)) - Includes designated module versions for the application.
  2. #majorVersionIds(List) (Builder#withMajorVersionIds(List)) - Includes designated versions of the default module for the application.
For a particular LogQuery only one of these methods may be used. If neither is used, LogService#fetch(LogQuery) results may include any module version.

It is not allowed to call both #versions(List) (Builder#withVersions(List)) and #requestIds(List)(Builder#withRequestIds(List) for the same LogQuery.

LogQuery.Builder

Contains static creation methods for LogQuery.

LogQuery.Version

Specifies a version of a module.

LogQueryResult

An object that is the result of performing a LogService.fetch() operation. LogQueryResults contain the logs from the user's query. Users of this service should use the LogQueryResult#iterator provided by this class to retrieve their results.

LogServiceFactory

Creates LogService implementations.

RequestLogs

RequestLogs contain all the log information for a single request. This includes the request log as well as any application logs (which may correspond to logging statements in the user's code or messages we have inserted to alert them to certain conditions we have noticed). Additionally, we include information about this request outside of those logs, such as how long the request took, the IP of the user performing the request, and so on.

Interfaces

ILogServiceFactory

Creates LogService implementations.

LogService

LogService allows callers to request the logs for an application using supplied filters. Logs are returned in an Iterable that yields RequestLogs, which contain request-level information and optionally AppLogLine objects containing the application logs from the request.

Enums

LogService.LogLevel

Exceptions

InvalidRequestException

Log errors caused by an invalid request due either to an out of range option or an unsupported combination of options. The exception detail will typically provide more specific information about the error.

LogServiceException

Log errors apart from InvalidRequestException. These errors will generally benefit from retrying the operation.