Log depth

I have a long running process in the backend and I saw that only the last 1000 logging calls are stored in the log for each request.

While this may not be a problem for an interface handler, I find it very inconvenient for a backend where the process can run indefinitely.

I tried clearing the logs to see if it was creating a new record, but it doesn't. This seems so wrong that I'm sure there should be a simple solution for this. Please, help!

Thanks stackoverflowians!

Update: Someone already asked this on the google appengine group, but there was no answer ...

Edit: The "depth" I'm linked to is not the total number of RequestLogs, that's ok, but the number of AppLogs in the RequestLog (which is capped at 1000).

Edit 2: I tried the following suggestions from David Papa:

def test_backends(self):
    launched = self.request.get('launched')
    if launched:
        #Do the job, we are running in the backend
        logging.info('There we go!')
        from google.appengine.api.logservice import logservice

        for i in range(1500):
            if i == 500:
                logservice.flush()
                logging.info('flushhhhh')
            logging.info('Call number %s'%i)
    else:
        #Launch the task in the backend
        from google.appengine.api import taskqueue
        tq_params = {'url': self.uri_for('backend.test_backends'),
                     'params': {'launched': True},
                     }
        if not DEBUG:
            tq_params['target'] = 'crawler'
        taskqueue.add(**tq_params)

      

Basically, this creates a backend task that logs 1500 rows, trickling out at 500. I expect to see two RequestLogs, the first has 500 rows and the second has 1000 rows.

The results are as follows:

  • I didn't get the result the documentation suggests , manually clearing the logs doesn't create a new log entry, I still have one RequestLog with 1000 lines. I already saw this part of the docs a while ago, but I had the same result, so I thought I didn't understand what the docs say. Anyway, at that time I left the call logservice.flush()

    in my backend code and the problem was not resolved.
  • I downloaded the logs using appcfg.py and guess what? ... all AppLogs are there! I usually look at the logs in the web interface, I'm not sure if I can get a convenient process to view the logs this way ... The ideal solution for me would be what is described in the docs.
  • My apps Autorun settings are set to default , I've played with them when at a time, but I've seen the problem persist, so I left them uninstalled.

I am using python;)

+3


source to share


2 answers


Google docs show that flushing should do exactly what you want. If your flush is working correctly, you will see "partial" request logs with the "flush" tag and the start time of the send request.

A few things to check:



  • Can you post your code that cleans up the logs? It may not work.
  • Are you using GAE Web Console to view logs? It is possible that the limit is just a web interface limit, and if you actually get the logs through the API, then all the data will be there. (This should only be a problem if the flush is not working properly.)
  • Check your application autorun settings .

I assume there are corresponding links for Java, if that's what you are using; you didn't say.

+1


source


Anything I can think of could help using a timed / cron script like below to run every hour or so from your workstation / server

appcfg.py --oauth2 request_logs appname/ output.log --append

      

This should give you a complete log - I haven't tested it myself

I read some more and it seems like CRON is already part of appcfg    https://developers.google.com/appengine/docs/python/tools/uploadinganapp#oauth



appcfg.py [options] cron_info <app-directory>
Displays information about the scheduled task (cron) configuration, including the
expected times of the next few executions. By default, displays the times of the
next 5  runs. You can modify the number of future run times displayed
with the -- num_runs=... option.

      

Based on your comment I would give it a try.

1) Write your own log class

2) Use multiple versions

0


source







All Articles