350-901 practice question 11 of 35

While developing an application following the 12-factor app methodology, which approach should be used in the application for logging?

Full set: 430 questions

Domain Application Deployment and Security

Answer options
A: Write a log to a file in the application directory.
B: Write a log to a file in /var/log.
C: Write the logs buffered to stdout.
D: Write the logs unbuffered to stdout. Correct answer
Correct Answer:
D. Write the logs unbuffered to stdout.
Explanation

The 12-factor app methodology, under Factor XI: Logs, prescribes that an application should treat logs as event streams. It must not concern itself with the routing or storage of its output. Instead, each running process should write its event stream, unbuffered, to standard output (stdout). The execution environment is then responsible for capturing this stream, collating it with other streams, and routing it to appropriate destinations for analysis and long-term storage. Writing unbuffered ensures that logs are not lost if the application crashes before a buffer is flushed.

Why Incorrect

A. Writing to a file in the application directory violates the principle that the application should not manage log files itself.
B. Writing to a file in /var/log also violates the principle of decoupling the application from log file management.
C. The methodology explicitly recommends writing unbuffered streams to stdout to ensure immediate capture and prevent log loss.

References

1. The 12-Factor App Methodology (Canonical Source): "XI. Logs". The official documentation states

"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. Instead

each running process writes its event stream

unbuffered

to stdout."

Source: https://12factor.net/logs

2. Official Vendor Documentation (Cloud Foundry): "Application Logging in Cloud Foundry". This documentation for a 12-factor compliant Platform-as-a-Service (PaaS) explains

"Cloud Foundry captures anything written to stdout or stderr by an application... This allows developers to treat logging as a stream and delegate the responsibility of consuming the stream to the platform."

Source: Cloud Foundry Docs

docs.cloudfoundry.org/devguide/deploy-apps/streaming-logs.html

Section: "How Application Logging Works".

3. University Courseware (UC Berkeley): "CS 162: Operating Systems and System Programming

Lecture 22: Cloud Computing". Slide 42 summarizes the 12-factor app principles

stating for Factor XI: "Logs: Treat logs as event streams. Write to stdout/stderr".

Source: UC Berkeley EECS

CS 162

Fall 2018

Lecture 22

Slide 42. https://inst.eecs.berkeley.edu/~cs162/fa18/static/lectures/22-Cloud.pdf

Scroll to Top