Courseiva
Development with AWS ServicesmediumMultiple ChoiceObjective-mapped

DVA-C02 Development with AWS Services Practice Question

A developer is using AWS Elastic Beanstalk to deploy a web application. The application writes logs to the local file system. The developer wants to ensure that logs are automatically rotated and retained for 30 days. What should the developer do?

⚠ Common exam trap

The trap here is that candidates often overcomplicate the solution by choosing CloudWatch Logs (Option D) because it is a common logging service, but the question specifically asks for automatic rotation and retention on the local file system, which Elastic Beanstalk's built-in feature handles directly without additional services.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Configure the Elastic Beanstalk environment to enable log rotation and set retention period to 30 days.

Elastic Beanstalk provides a built-in configuration for log rotation and retention directly in the environment settings. By enabling log rotation and setting the retention period to 30 days, the developer can automatically manage logs without modifying application code or adding external agents. This leverages the Elastic Beanstalk health agent, which handles log rotation on the EC2 instances and stores rotated logs in Amazon S3 with lifecycle policies to enforce the retention period.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Modify the application code to write logs directly to an S3 bucket with lifecycle policies.

    Why it's wrong here

    Modifying application code to directly write logs to an S3 bucket introduces unnecessary complexity and tightly couples the application logic with infrastructure concerns. This approach fails to address the critical need for local log rotation on the EC2 instances, potentially leading to disk space exhaustion if not carefully managed. Furthermore, it bypasses Elastic Beanstalk's native logging mechanisms, making troubleshooting and integration with other AWS services more cumbersome.

  • Add a cron job to the EC2 instances that compresses and deletes old logs.

    Why it's wrong here

    Implementing a custom cron job on EC2 instances for log management is a manual, unmanaged solution that contradicts the benefits of using Elastic Beanstalk's managed environment. This approach requires custom configuration scripts, complicates environment updates, and is not automatically propagated across instances during scaling events. It introduces significant operational overhead and reduces the reproducibility and consistency of the environment.

  • Configure the Elastic Beanstalk environment to enable log rotation and set retention period to 30 days.

    Why this is correct

    Elastic Beanstalk provides built-in environment properties to manage log rotation and retention directly, making it the most appropriate and integrated solution for this requirement. Developers can configure settings like `LogRotationPeriod` and `LogRotationSizeThreshold` through the Elastic Beanstalk console, CLI, or configuration files. This ensures local log files are automatically rotated and old logs are removed, preventing disk space issues without requiring custom code or manual scripts.

  • Install the CloudWatch Logs agent on the EC2 instances and configure it to stream logs to CloudWatch Logs with a 30-day retention.

    Why it's wrong here

    While installing the CloudWatch Logs agent is excellent for centralizing logs and setting retention in CloudWatch Logs, it primarily streams logs and does not inherently manage local log file rotation on the EC2 instances. Without local rotation, log files can still accumulate on the instance's disk, potentially leading to disk space issues over time. Elastic Beanstalk's native log rotation features are specifically designed to handle this local file management.

Quick reference

AWS S3 Storage Class Comparison

Storage ClassMin DurationRetrievalUse Case
S3 StandardNoneImmediateFrequently accessed data
S3 Standard-IA30 daysImmediateInfrequent access, rapid retrieval
S3 One Zone-IA30 daysImmediateNon-critical infrequent data
S3 Intelligent-TieringNoneImmediate–hoursUnknown or changing access patterns
S3 Glacier Instant90 daysMillisecondsArchive with instant retrieval
S3 Glacier Flexible90 daysMinutes–hoursArchive, flexible retrieval
S3 Glacier Deep Archive180 daysHoursLong-term compliance archive

About these practice questions

One of 724 original DVA-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This DVA-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DVA-C02 exam.