PHP 5 has reached end of support and will be
deprecated
on January 31, 2026. After deprecation, you won't be able to deploy PHP 5
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing PHP
5 applications will continue to run and receive traffic after their
deprecation date. We recommend that
you
migrate to the latest supported version of PHP.
\google\appengine\api\log\LogService
Stay organized with collections
Save and categorize content based on your preferences.
FINAL
The LogService allows an application to query for request and application
logs. Application logs are added to a the current request log by calling
{@link http://php.net/manual/en/function.syslog.php syslog(int $priority,
string $message)}. The $priority used when creating the application log is
translated into a different scale of severity used by the LogService based
on the following mappings,
- LOG_DEBUG => LogService::LEVEL_DEBUG
- LOG_INFO => LogService::LEVEL_INFO
- LOG_NOTICE => LogService::LEVEL_INFO
- LOG_WARNING => LogService::LEVEL_WARNING
- LOG_ERR => LogService::LEVEL_ERROR
- LOG_CRIT => LogService::LEVEL_CRITICAL
- LOG_ALERT => LogService::LEVEL_CRITICAL
- LOG_EMERG => LogService::LEVEL_CRITICAL
When fetching application logs or filtering request logs by severity use the
LogService's severity levels.
Uses traits
\google\appengine\api\log\ApiProxyAccess
Constants
LEVEL_DEBUG
Constants for application log levels.
LEVEL_INFO
LEVEL_WARNING
LEVEL_ERROR
LEVEL_CRITICAL
MAX_BATCH_SIZE
The maximum number of request logs returned in each batch.
Methods
fetch
STATIC
fetch(array $options = array()) : \google\appengine\api\log\Iterator
Get request logs matching the given options in reverse chronological
order of request end time.
Parameters
Name |
Description |
$options
|
array
Optional associateive arrary of filters and
modifiers from following:
- 'start_time':
DateTime or numeric The earliest
completion time or last-update time for request logs. If the value is
numeric it represents microseconds since Unix epoch.
- 'end_time':
DateTime or numeric The latest completion
time or last-update time for request logs. If the value is numeric it
represents microseconds since Unix epoch.
- 'offset':
string The url-safe offset value from a
RequestLog to continue iterating after.
- 'minimum_log_level':
integer Only return request logs
containing at least one application log of this severity or higher.
Works even if include_app_logs is not true
- 'include_incomplete':
boolean Should incomplete request
logs be included. The default is false - only completed
logs are returned
- 'include_app_logs':
boolean Should application logs be
returned. The default is false - application logs are not
returned with their containing request logs.
- 'versions':
array The versions of the default module
for which to fetch request logs. Only one of 'versions' and
'module_versions' can be used.
- 'module_versions':
arrary An associative array of module
names to versions for which to fetch request logs. Each module name may
be mapped to either a single string version or an
array of versions.
- 'batch_size':
integer The number of request logs to
pre-fetch while iterating.
|
Returns
\google\appengine\api\log\Iterator
The matching RequestLog items.
fetchById
STATIC
fetchById(mixed $request_ids, boolean $include_app_logs = true) : array<mixed,\google\appengine\api\log\RequestLog>
Get request logs for the given request log ids and optionally include the
application logs addded during each request. Request log ids that are not
found are ignored so the returned array may have fewer items than
$request_ids.
Parameters
Name |
Description |
$request_ids
|
mixed
A string request id or an array of string request
ids obtained from RequestLog::getRequestId() . |
$include_app_logs
|
boolean
Should applicaiton logs be included in the
fetched request logs. Defaults to true - application logs are included. |
Returns
array<mixed,\google\appengine\api\log\RequestLog>
The request logs for ids that were found.
log
STATIC
log(integer $severity, string $message)
Add an app log at a particular Google App Engine severity level.
Parameters
Name |
Description |
$severity
|
integer
The Google App Engine severity level for the log. |
$message
|
string
The message to log. |
flush
STATIC
flush()
Write all buffered log messages to the log storage. Logs may not be
immediately available to read.
setAutoFlushEntries
STATIC
setAutoFlushEntries(integer $entries)
Set the maximum number of log entries to buffer before they are
automaticallly flushed upon adding the next log entry.
Parameters
Name |
Description |
$entries
|
integer
Number of log entries to buffer. |
setAutoFlushBytes
STATIC
setAutoFlushBytes(integer $bytes)
Sets the maximum size of logs to buffer before they are automaticallly
flushed upon adding the next log entry.
Parameters
Name |
Description |
$bytes
|
integer
Size of logs to buffer in bytes. |
setLogFlushTimeLimit
STATIC
setLogFlushTimeLimit(integer $seconds)
Sets the maximum amount of time in seconds before the buffered logs are
automatically flushed upon adding the next log entry.
Parameters
Name |
Description |
$seconds
|
integer
Time in seconds. Use zero or negative value to
disable the time limit. |
getAppEngineLogLevel
STATIC
getAppEngineLogLevel(integer $syslog_level) : integer
Translates a PHP syslog priority level into a Google App
Engine severity level. Useful when filtering logs by minimum severity
level given the syslog level.
Parameters
Name |
Description |
$syslog_level
|
integer
The priority level passed to
syslog . |
Returns
integer
The app engine severity level.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-06-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-16 UTC."],[[["\u003cp\u003eThe LogService enables applications to query for request and application logs, with application logs added via the \u003ccode\u003esyslog()\u003c/code\u003e function.\u003c/p\u003e\n"],["\u003cp\u003eThe severity levels used in \u003ccode\u003esyslog()\u003c/code\u003e calls are mapped to LogService's severity levels, such as \u003ccode\u003eLOG_DEBUG\u003c/code\u003e mapping to \u003ccode\u003eLogService::LEVEL_DEBUG\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003efetch()\u003c/code\u003e allows retrieval of request logs in reverse chronological order based on various criteria like time, severity, and versions, while \u003ccode\u003efetchById()\u003c/code\u003e retrieves specific request logs by their IDs.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003elog()\u003c/code\u003e function adds a new application log at a specified severity level, and \u003ccode\u003eflush()\u003c/code\u003e is used to write all buffered log messages to the log storage.\u003c/p\u003e\n"],["\u003cp\u003eThe LogService offers configuration options to manage log buffering, such as \u003ccode\u003esetAutoFlushEntries()\u003c/code\u003e, \u003ccode\u003esetAutoFlushBytes()\u003c/code\u003e, and \u003ccode\u003esetLogFlushTimeLimit()\u003c/code\u003e to control automatic flushing of log entries.\u003c/p\u003e\n"]]],[],null,["# \\google\\appengine\\api\\log\\LogService\n\nFINAL\n\nThe LogService allows an application to query for request and application\nlogs. Application logs are added to a the current request log by calling\n{@link \u003chttp://php.net/manual/en/function.syslog.php\u003e syslog(int $priority,\nstring $message)}. The $priority used when creating the application log is\ntranslated into a different scale of severity used by the LogService based\non the following mappings,\n\n- LOG_DEBUG =\\\u003e LogService::LEVEL_DEBUG\n- LOG_INFO =\\\u003e LogService::LEVEL_INFO\n- LOG_NOTICE =\\\u003e LogService::LEVEL_INFO\n- LOG_WARNING =\\\u003e LogService::LEVEL_WARNING\n- LOG_ERR =\\\u003e LogService::LEVEL_ERROR\n- LOG_CRIT =\\\u003e LogService::LEVEL_CRITICAL\n- LOG_ALERT =\\\u003e LogService::LEVEL_CRITICAL\n- LOG_EMERG =\\\u003e LogService::LEVEL_CRITICAL\n\nWhen fetching application logs or filtering request logs by severity use the\nLogService's severity levels.\n\nUses traits\n-----------\n\n\n\\\\google\\\\appengine\\\\api\\\\log\\\\ApiProxyAccess\n\nConstants\n---------\n\n### LEVEL_DEBUG\n\nConstants for application log levels.\n\n### LEVEL_INFO\n\n### LEVEL_WARNING\n\n### LEVEL_ERROR\n\n### LEVEL_CRITICAL\n\n### MAX_BATCH_SIZE\n\nThe maximum number of request logs returned in each batch.\n\nMethods\n-------\n\n### fetch\n\n\nSTATIC\n\n`fetch(array `$options = array()`) : \\google\\appengine\\api\\log\\Iterator`\n\nGet request logs matching the given options in reverse chronological\norder of request end time.\n\n#### Parameters\n\n#### Returns\n\n`\\google\\appengine\\api\\log\\Iterator`\n\nThe matching RequestLog items.\n\n### fetchById\n\n\nSTATIC\n\n`fetchById(mixed `$request_ids`, boolean `$include_app_logs = true`) : array\u003cmixed,\\google\\appengine\\api\\log\\RequestLog\u003e`\n\nGet request logs for the given request log ids and optionally include the\napplication logs addded during each request. Request log ids that are not\nfound are ignored so the returned array may have fewer items than\n$request_ids.\n\n#### Parameters\n\n#### Returns\n\n`array\u003cmixed,`[\\google\\appengine\\api\\log\\RequestLog](../classes/google.appengine.api.log.RequestLog.html)`\u003e`\n\nThe request logs for ids that were found.\n\n### log\n\n\nSTATIC\n\n`log(integer `$severity`, string `$message`) `\n\nAdd an app log at a particular Google App Engine severity level.\n\n#### Parameters\n\n### flush\n\n\nSTATIC\n\n`flush() `\n\nWrite all buffered log messages to the log storage. Logs may not be\nimmediately available to read.\n\n### setAutoFlushEntries\n\n\nSTATIC\n\n`setAutoFlushEntries(integer `$entries`) `\n\nSet the maximum number of log entries to buffer before they are\nautomaticallly flushed upon adding the next log entry.\n\n#### Parameters\n\n### setAutoFlushBytes\n\n\nSTATIC\n\n`setAutoFlushBytes(integer `$bytes`) `\n\nSets the maximum size of logs to buffer before they are automaticallly\nflushed upon adding the next log entry.\n\n#### Parameters\n\n### setLogFlushTimeLimit\n\n\nSTATIC\n\n`setLogFlushTimeLimit(integer `$seconds`) `\n\nSets the maximum amount of time in seconds before the buffered logs are\nautomatically flushed upon adding the next log entry.\n\n#### Parameters\n\n### getAppEngineLogLevel\n\n\nSTATIC\n\n`getAppEngineLogLevel(integer `$syslog_level`) : integer`\n\nTranslates a PHP syslog priority level into a Google App Engine severity level. Useful when filtering logs by minimum severity level given the syslog level.\n\n#### Parameters\n\n#### Returns\n\n`integer`\n\nThe app engine severity level."]]