GAE app logs tail to include app's log , not just http request log

gcloud app logs tail -s default
gcloud app logs read
google app engine log viewer
gcloud functions logs read
stackdriver logging log viewer
stackdriver custom logs
stackdriver logs not showing
gcloud list sinks

After deploying an app (made of spring boot and kotlin) to Google App Engine , I can use $ gcloud app logs tail to monitor the latest logs :

But it doesn't show logs output by applications. I have to use browser to go to StackDriver to browse online logs . This is not convenient.

Another way is to use command line to read request_log by gcloud logging command :

gcloud logging read request_log --limit=10

But it doesn't support tail mode , and it outputs too much payload data (such as labels , requestId , zone ... blah...). I tried many formats but still output too much payloads.

I just want to see what's output by logger.info("...") or higher level

Is there any way for gcloud app logs tail also output logs by apps ? Or any other way to tail (monitor) app's log in the console ?

The logging code is simple (by slf4j) :

@RestController
class WebhookController {

  val logger = LoggerFactory.getLogger(javaClass)!!

  @GetMapping("/")
  fun index(req: HttpServletRequest): String {
    logger.info("header : ")
    for (headerName in req.headerNames) {
      logger.info("\t{} = {}", headerName, req.getHeader(headerName))
    }
    logger.info("params : ")
    req.parameterMap.forEach { (k, v) ->
      logger.info("\t{} = {}", k, v)
    }
    return "Hello Spring Boot Kotlin "
  }
}

Environment :

logging.properties

.level = INFO
handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=INFO

appengine-web.xml

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
  <version>1</version>
  <threadsafe>true</threadsafe>
  <runtime>java8</runtime>
  <system-properties>
    <property name="java.util.logging.config.file" value="logging.properties"/>
  </system-properties>
</appengine-web-app>

and

Google Cloud SDK 220.0.0
app-engine-java 1.9.66
<kotlin.version>1.2.71</kotlin.version>
<springboot.version>2.0.5.RELEASE</springboot.version>
<spring.version>5.0.8.RELEASE</spring.version>

updated : StackDriver in browser sample : I am only interested in the red-circled part. But not output in gcloud app logs tail

Your application logs should be going into the stdout stream, which you can select using the --logs option of the gcloud app logs tail command.

gcloud app logs tail --logs=stdout

See: https://cloud.google.com/sdk/gcloud/reference/app/logs/tail

GAE app logs tail to include app's log , not just http request log , Your application logs should be going into the stdout stream, which you can select using the --logs option of the gcloud app logs tail command. Groundbreaking solutions. Transformative know-how. Whether your business is early in its journey or well on its way to digital transformation, Google Cloud's solutions and technologies help chart a path to success.

This is a bit hacky but what you can do is:

  1. Use watch -n 1 to run the command every second (tail-like workaround)
  2. Use gcloud logging read "request_log" --limit=10 --format=json to format it as json so that you can then parse it with jq
  3. Pipe the output to jq so that it prints only the log message instead of all the other payload data, for example jq ".[].protoPayload.line | .[] | .logMessage"

So the full command would be:

watch -n 1 'gcloud logging read "request_log" --limit=10 --format=json | jq ".[].protoPayload.line | .[] | .logMessage"'

So if the log entry is like this:

[
  {
    "httpRequest": {
      "status": 200
    },
    ...,
    "protoPayload": {
      "@type": "type.googleapis.com/google.appengine.logging.v1.RequestLog",
      ...
      "line": [
        {
          "logMessage": "This is an info message",
          "severity": "INFO",
          ...

        }
      ]
    }
    ...
  }
]

Then with jq ".[].protoPayload.line | .[] | .logMessage" you'll be getting only this:

"This is an info message"

You can also add .time so that you get the timestamp of the log message:

jq ".[].protoPayload.line | .[] | .logMessage ,.time"

Write and view logs, log . You're familiar with Cloud logging (formerly StackDriver logging) and prefer to use it for custom logging. Using the Cloud Functions logger  The Cloud SDK has a group of commands, gcloud logging, that provide a command-line interface to the Logging API.A summary of the important commands and examples of their use are shown on this page.

Give a try to the beta version of the tool!

With something like gcloud beta app logs tail --project=... --logs=stdout,stderr, I get the expected traces from my live code.

Google App Engine, When you sign up for Google App Engine, it offers a certain amount of free credits which will not be gcloud app logs tail --project=myapi-123456 -s default. When paired with a compatible Garmin Varia™ device¹, the Varia™ app has the tools you need to ride with confidence. Using the Varia™ app, you can: • Be alerted right on your phone when approaching vehicles are within 140 meters behind your bicycle. • View color-coded alerts based on surrounding traffic: Green means you’re all clear, yellow means a vehicle is approaching, and red

I am using laravel and had same problem. Finally, I add in my app.yaml add

env_variables:
    ...
    LOG_CHANNEL: stderr

And thats helps me tailing app Logs like that:

Log::info( $data );

And as a recommendation, $data shoud be like JSON - for easy reading throu console.

Deploy a Spring Boot Application to Google App Engine, Deploy a Spring Boot Application to Google App Engine Configure Google Cloud Platform Console and SDK; Use Cloud SQL to create a MySQL instance; Configure view. gcloud app logs read. # tail. gcloud app logs tail  It's all there in the system log, aka logcat! What makes CatLog stand out over similar apps? * Color-coded tag names * Easy-to-read column display * Real-time search * Recording mode (with widget) * Save & open from SD card * Send logs as email or attachment * Auto-scrolls when at the bottom of the screen (just like tail -f) * Search

Google App Engine – Instana Documentation, Google App Engine (GAE) is a highly scalable application system on a fully managed serverless platform. RUN apk update && \ apk --update add openjdk8-jre ADD org.ops4j.pax.logging.cfg /root/ ADD gcloud app logs tail -s gae-java-app. Play the best free Apps on GamesGames.com. Are you an existing user? Then log in to see your favorited games here! Don't have an account yet?

How to deploy ASP.NET Core 3.x to Google App Engine, deploying an ASP.NET Core 3.x application to Google Cloud Engine…. NET Core & Docker, with a GCP account to use. or streamed directly through the CLI (https://cloud.google.com/sdk/gcloud/reference/app/logs/tail): Loggregator assigns the timestamp when it receives log data. The log data is opaque to Loggregator, which simply puts it in the message field of the log line. Apps or system components sending log data to Loggregator may include their own timestamps, which then appear in the message field. Origin codes distinguish the different log types.

Exam Ref AZ-203 Developing Solutions for Microsoft Azure, /LogFiles/Application/This folder contains the logs files from the application logging. The XML files contain the actual tracing information, while the XSL file az webapp log tail --resource-group <Resouce group name> --name <App name> to hear, a message from a friend, or the position of other players in the game. GAE + Django 3.0 production-ready app using cookiecutter in 5 minutes. gcloud app deploy. You can stream logs from the command line by running: $(gaevenv) gcloud app logs tail -s default.

Comments
  • Sorry , it doesn't work. In fact , the default --logs contains stderr,stdout,crash.log,nginx.request,request_log .
  • Yes , I mentioned I have to use browser to go to StackDriver to browse online logs . This is not convenient. It has a lot of payloads.
  • So, in the browser, under which log stream do the logs appear? Is it stdout? In that case you're saying there is a bug in gcloud. Correct?
  • I've appended a StackDriver snapshot , FYI. There is <stdout> , but not output by gcloud app logs tail
  • Please consider adding some explanation or details to your answer. While it might answer the question, just adding a piece of code as an answer, doesn't per say help OP or future community members understand the issue or the proposed solution.