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.
4. Go to browser and replace
“setup?type=system&platform=unix” with “new”
5. Select “I use cloud foundry” and save.
6. It will navigate to a screen and show the location fro log drain e.g logs7.papertrailapp.com:42067
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>
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.
13. Click on system link and you can find “pcfwelcome” application log in papertrail.
Congratulation, we have successfully drain log in Papertrail. See you at next post, till then happy coding.