Re: REST API endpoint for accessing application logs


Rohit Kumar
 

The API endpoint to get recent logs is present on the loggregator
trafficontroller. You can get the URL for your traffic controller by
running:

cf curl /v2/info | jq .doppler_logging_endpoint

Note that, the URL which you get back will have a "wss" spec, but you will
need to use "https" when you issue a recentlogs request.

To get the recent logs for your application, you should issue a GET request
to https://<trafficontroller URL>/apps/<appid>/recentlogs . You will also
need to provide your CF oauth token as part of the "Authorization" header
for this request. For example:

curl -k -H "Authorization: $(cf oauth-token | grep bearer)"
https://doppler.bosh-lite.com:443/apps/$(cf app appName --guid)/recentlogs

The response body will contain the log messages in the dropsonde-protocol
<https://github.com/cloudfoundry/dropsonde-protocol>format, so you will
need to parse them. If you are using Go to do this an easier way would be
to use the NOAA library to get recentlogs
<https://github.com/cloudfoundry/noaa/blob/master/sample/main.go#L17-L29>.

Rohit

On Tue, Oct 13, 2015 at 6:11 AM, Ponraj E <ponraj.e(a)gmail.com> wrote:

Hi,

I want to get the application's dumped logs from the loggregator and not
the tailing logs.
CLI provides me a command to do it: cf logs APP_NAME --recent displays
all the lines in the Loggregator buffer.

But how do I do it via REST API endpoint? I had set the CF_TRACE=true to
see the REST calls thats been fired to get the application log, but I see
only the GET call to get the application details, but after that it just
dumps the log.

Thanks for the help.

Regards,
Ponraj

Join cf-dev@lists.cloudfoundry.org to automatically receive all group messages.