1

Reading and Writing Application Logs discusses the difference between Request logs vs application logs.

In main.py running on App Engine I import logging and grab a logger (since it's named, options_log, I'm not using root logger):

import logging

log = logging.getLogger('options_log')
log.setLevel(logging.INFO)
...

log.info('Hello Log!')

I can't find any information on where to view my application logs in the Developer Console. I see only request_log and activity.

enter image description here

The request_log contains logging from main.py, but how do I log to application log and not request_log?

Community
  • 1
  • 1
Jack
  • 10,313
  • 15
  • 75
  • 118

1 Answers1

2

You don't need to set the logger options, just importing the logging module and invoking its functions should suffice, just like the in examples on the page you referenced:

import logging

import webapp2


class MainPage(webapp2.RequestHandler):
    def get(self):
        logging.debug('This is a debug message')
        logging.info('This is an info message')

You should also note that the application logs can not be seen independently, they are always attached to the request log for the request in response to which they were produced. From the doc you referenced:

Each request log contains a list of application logs (AppLog) associated with that request, returned in the RequestLog.app_logs property. Each app log contains the time the log was written, the log message, and the log level.

Note: A request log can only hold 1000 app logs. If you add more than 1000,
the older logs will not be retained.

You need to click on the left-most caret to expand the request log entry to display the respective app log(s):

enter image description here

If after expanding the request log you still don't see your app logs I suspect that your attempt to set options on a specific logger - the 'options_log' one - might be your problem. If you still want to set options, try doing it for the default logger (root logger?) instead of specifying one. Or drop the options altogether.

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • Accepting this since it answers my question perfectly. However, if application logs are interleaved with `request_logs`, how can `filters` be used to extract only application logs, for example, to create exports to `sinks`? – Jack Apr 23 '17 at 09:19
  • Filtering works normally and whenever some app logs match the filter they will be displayed *together* with the respective "carrying" request logs they're attached to. – Dan Cornilescu Apr 23 '17 at 12:41