Log Drains – How to manage log in PCF with Parertrail

A twelve-factor app never concerns itself with routing or storage of its output stream. It should not attempt to write to or manage logfiles. PCF provides several options for log drain. Since we pushed our application successfully , now time to explore how to deal with logs. Let’s do it step by step again:

1.  Go to papertrail and open an account.
2. Log in to your account and navigate to “Dashboard”.
3. Click “Add your first system” link.

How to log drain in PCF
Papertrail log drain.

4.  Go to browser and replace “setup?type=system&platform=unix” with “new”

new_log_paper_trail
new log papertrail

5. Select “I use cloud foundry” and save.

How to link papertrail and pcf.
Link Papertrail and PCF

6. It will navigate to a screen and show the location fro log drain e.g  logs7.papertrailapp.com:42067

how to create ssystem in papretrail for log drain.
new system created for log

7.  Log in to “cf cli” and navigate to organisation “devworld” and space “development”.

8. Create a user provided service ( do not worry, we shall discuss service later) with the below command
cf create-user-provided-service pcfwelcome_log -l syslog://<your papertrail log drain location>
Format is: cf create-user-provided-service  <your service name , any name of your choice> -l syslog://<papertrail log drain location>

service_for_log_drain
Create service for log drain

9. Bind “pcfwelcome_log” service with “pcfwelcome” application. Use the command:
cf bind-service pcfwelcome pcfwelcome_log
Format is : cf bind-service <application name> <service to bind>

10. Go to your browser and paste your application url appended with end point /welcome. Refer  “How to push application in pcf” – step 10.

11. Refresh the browser several times to generate more log.

12. Log in papertrail and go to dashboard. You can see the system created for “pcfwelcome” log drain. You can click “edit” and give meaningful name of the system.

log drain in papertrail
Log drain system in papertrail

13. Click on system link and you can find “pcfwelcome” application log in papertrail.

PCF log in papertrail.
PCF log in papertrail.

 

Congratulation, we have successfully drain log in Papertrail. See you at next post, till then happy coding.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.