Logging from an application on CloudFoundry
Sending logs from an application on CloudFoundry to some logging service
In CloudFoundry by default app logs are included in syslog drains. So if syslog drain endpoint is provided to application the logs will be sent to that endpoint.
Assumptions/ Prerequisites
- You have
cf
cli installed on your machine. - You have correct permissions to create user provided service on CloudFoundry
Steps to follow
Below is a very simple guide to send logs from an application running on CloudFoundry to a logging service for example logstash. What you need to do is create a user-provided service on CloudFoundry, and bind your app to this service.
- Create a user-provided service
1cf cups SERVICE_INSTANCE_NAME -l syslog://some.log-aggregator.url
- Bind your application to the above created service.
1cf bind-service APPLICATION_NAME SERVICE_INSTANCE_NAME
- To make this changes effective restage the application.
1cf restage APPLICATION_NAME
Login to you logging service and verify if the logs from application are visible there.