Course contentsShow
← Software Engineering
Lesson 753 of 1,93323. Configuration ManagementFree lesson

Logs and Admin Processes Factors

Treating logs as event streams routed to centralized systems and running admin tasks as one-off processes.

Logs and Admin Processes Factors

What you'll learn: How the Twelve-Factor App methodology recommends treating logs as streams and running admin tasks as one-off processes.

Treating Logs as Event Streams

In traditional applications, developers often write logs to files on disk and manage rotation, cleanup, and searching manually. The Twelve-Factor methodology takes a different approach: your application should never manage log files directly.

Instead, think of logs as a continuous stream of events — like water flowing through a pipe. Your application writes log entries to standard output (stdout) and standard error (stderr), and that's it. Something else (the execution environment, a log aggregator, or a service like CloudWatch or Splunk) captures those streams and routes them to appropriate destinations.

This decouples your app from log storage concerns. In development, logs appear in your terminal. In production, they're captured by centralized logging infrastructure where they can be searched, analyzed, and retained according to your needs — all without changing application code.

Admin Processes as One-Off Tasks

Applications often need administrative or maintenance tasks: running database migrations, cleaning up old data, or executing one-time scripts. The Twelve-Factor approach says these admin processes should run in identical environments to your regular application processes.

Run them as one-off commands using the same codebase, dependencies, and configuration. For example, if your app runs in containers, run your migration script in the same container image. This ensures admin tasks have access to the same environment variables, backing services, and code version as your running application.

Avoid maintaining separate admin scripts with different configurations or dependencies — this creates consistency and debugging nightmares.

Key Takeaway: Treat logs as event streams routed to centralized systems rather than files your app manages, and run admin tasks as one-off processes in the same environment as your application to maintain consistency and simplicity.