Good monitoring for a short backend internship project means three things: consistent log levels, structured (JSON) log lines that carry a request ID, and a small health-check endpoint that reports whether the app and its dependencies are working. You can build all of this in a day or less, and it makes your demo far easier to defend. This guide gives you the conventions, code, a 14-day schedule and a log-review checklist.
Why logging matters more than features in a 14-day project
In a two-week project you will have bugs on demo day. A reviewer who asks “what happens if the database is down?” or “show me a failed request” is testing whether you understand your own system. Logs let you answer with evidence instead of guesses. They also give you something concrete to describe in your report: what you recorded, why, and what you learned from it.
The free two-week online internship from CareerSwami comes with a free offer letter and a free completion certificate after successful completion. Whatever track you take, a project that shows its own behaviour clearly is easier to explain and to present in a portfolio.
Log-level conventions for a Python backend project
Pick one convention at the start and apply it everywhere. Python’s standard logging module provides the levels below. The “use it for” column is a suggested team convention, not an official rule.
| Level | Use it for | Example event | Visible in production? |
|---|---|---|---|
| DEBUG | Detail useful only while developing | Parsed query parameters, SQL timing | No |
| INFO | Normal, meaningful events | Request completed, user created, job started | Yes |
| WARNING | Unexpected but handled | Retry on a slow API, invalid input rejected, deprecated endpoint used | Yes |
| ERROR | An operation failed | Database write failed, upstream call returned 500 | Yes, worth alerting |
| CRITICAL | The app cannot continue | Cannot connect to database at startup, missing secret | Yes, urgent |
Rules that keep levels honest
- A 4xx caused by a client mistake is usually INFO or WARNING, not ERROR. Reserve ERROR for failures on your side.
- Log an exception once, where you handle it, using
logger.exception(...)so the traceback is included. Logging it at every layer creates duplicate noise. - Never log passwords, tokens, API keys, full card or Aadhaar-type identifiers, or complete request bodies containing personal data.
- Use a named logger per module (
logging.getLogger(__name__)) so you can see where a line came from. - Keep DEBUG off by default and switch it on with an environment variable such as
LOG_LEVEL=DEBUG.
Free 2-Week CareerSwami Internship
Online, 14 days, with a free offer letter and a free completion certificate once you finish the work. Check with your college that it fits your requirement before you enrol.
Setting up structured JSON logs with the standard library
Plain text lines are fine to read but hard to filter. Structured logs put each event in key-value form so you can search by field. The snippet below is illustrative: it shows the pattern, and you should run and adapt it in your own project.
import json, logging, os, sys, time
class JsonFormatter(logging.Formatter):
def format(self, record):
payload = {
"ts": time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime(record.created)),
"level": record.levelname,
"logger": record.name,
"message": record.getMessage(),
}
for key in ("request_id", "method", "path", "status", "duration_ms"):
if hasattr(record, key):
payload[key] = getattr(record, key)
if record.exc_info:
payload["exception"] = self.formatException(record.exc_info)
return json.dumps(payload)
def setup_logging():
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(JsonFormatter())
root = logging.getLogger()
root.handlers = [handler]
root.setLevel(os.getenv("LOG_LEVEL", "INFO"))
Writing to standard output keeps things simple: your terminal, a container runtime or a hosting platform can collect it without extra configuration. If you also want a file, add a RotatingFileHandler so the file does not grow without limit.
A recommended set of fields
- ts: timestamp, ideally in UTC or with a consistent zone.
- level and logger: severity and module.
- message: a short fixed sentence, such as “order created”, not a sentence with values glued in.
- request_id: one identifier per incoming request, repeated on every line it causes.
- method, path, status, duration_ms: the basics of each request.
Adding a request ID and timing to every request
A request ID lets you follow one request across many log lines. In FastAPI, a middleware does this in a few lines. This is an illustrative sketch, not tested code from the article.
import logging, time, uuid
from fastapi import FastAPI, Request
app = FastAPI()
log = logging.getLogger("app.http")
@app.middleware("http")
async def log_requests(request: Request, call_next):
rid = request.headers.get("x-request-id", str(uuid.uuid4()))
start = time.perf_counter()
try:
response = await call_next(request)
except Exception:
log.exception("unhandled error", extra={"request_id": rid,
"method": request.method, "path": request.url.path})
raise
ms = round((time.perf_counter() - start) * 1000, 1)
log.info("request completed", extra={"request_id": rid,
"method": request.method, "path": request.url.path,
"status": response.status_code, "duration_ms": ms})
response.headers["x-request-id"] = rid
return response
Flask and Django have equivalents (before_request/after_request hooks, or middleware classes). The idea is the same in any framework.
A basic health-check endpoint for your Python API
A health endpoint answers one question: is this service able to do its job right now? Keep it fast and free of side effects. Many teams separate two ideas: liveness (the process is running) and readiness (dependencies such as the database are reachable).
import sqlite3, time
START = time.time()
@app.get("/health")
def health():
return {"status": "ok", "uptime_s": round(time.time() - START)}
@app.get("/ready")
def ready():
checks = {}
try:
conn = sqlite3.connect("app.db", timeout=1)
conn.execute("SELECT 1")
conn.close()
checks["database"] = "ok"
except Exception:
log.exception("readiness check failed")
checks["database"] = "down"
ok = all(v == "ok" for v in checks.values())
from fastapi.responses import JSONResponse
return JSONResponse({"status": "ready" if ok else "degraded",
"checks": checks},
status_code=200 if ok else 503)
- Return HTTP 200 when healthy and 503 when a dependency is down, so a script or hosting platform can act on the status code alone.
- Do not expose secrets, version strings you would rather keep private, or connection strings in the response.
- Do not write to the database in a health check.
- Avoid logging every health probe at INFO if a platform pings it every few seconds; use DEBUG for those lines.
Worked example: tracing a failed order request from log lines
This scenario is illustrative, not a real project. Imagine a small order API where a client posts an order and gets a 500. With structured logs, the relevant lines might look like this:
{"ts":"2026-11-20T10:14:02","level":"INFO","logger":"app.orders","message":"order received","request_id":"a1f3","path":"/orders"}
{"ts":"2026-11-20T10:14:03","level":"WARNING","logger":"app.db","message":"retrying write","request_id":"a1f3","attempt":2}
{"ts":"2026-11-20T10:14:04","level":"ERROR","logger":"app.db","message":"write failed","request_id":"a1f3","exception":"OperationalError: database is locked"}
{"ts":"2026-11-20T10:14:04","level":"INFO","logger":"app.http","message":"request completed","request_id":"a1f3","status":500,"duration_ms":2011.4}
Searching for a1f3 gives the whole story: the request arrived, the write was retried, the database was locked, and the client received a 500 after about two seconds. The fix might be a longer timeout, a smaller transaction or a different database for concurrent writes. Your demo explanation then becomes: symptom, evidence in the logs, cause, fix, and a log line showing the fixed behaviour.
A 14-day plan for adding monitoring without slowing feature work
| Days | Logging and monitoring task | Output |
|---|---|---|
| 1-2 | Agree level conventions, set up setup_logging(), choose field names |
Logging module committed |
| 3-5 | Add request-ID middleware; log key business events at INFO | Every request produces one completion line |
| 6-7 | Add /health and /ready; test by stopping the database |
200 and 503 behaviours confirmed |
| 8-10 | Handle errors with logger.exception; remove duplicate or noisy logs; check for sensitive data |
Clean log sample |
| 11-12 | Trigger two or three deliberate failures and save the matching log lines | Evidence for the report |
| 13 | Run the log-review checklist below; fix gaps | Checklist ticked |
| 14 | Rehearse the demo, including one failure walk-through | Demo ready |
Log-review checklist for demo day
Run through this on day 13 with the app running and the log output visible.
- Does every request produce at least one log line with a request ID, method, path, status and duration?
- Can you pick one request ID and find every line connected to it?
- Are levels used consistently, with no routine success messages at ERROR and no failures hidden at DEBUG?
- Is each exception logged once with a traceback?
- Have you searched the output for passwords, tokens, keys and personal data, and found none?
- Does
/healthreturn 200 while the app runs, and does/readyreturn 503 when you stop the database? - Is the log level controlled by an environment variable rather than edited in code?
- Are messages short and fixed, with variable values in separate fields?
- Do you have saved log excerpts from at least one deliberate failure for your report or slides?
- Can you explain, in one minute, what you would alert on if this ran for real?
VIT Bhopal students: fitting logging evidence into your internship paperwork
VIT Bhopal says its curriculum includes a 2-credit Internship course, and the same page says students apply for and obtain internships through the Placement and Training Cell’s industry contacts in the third year (the page carries a 2024 date, so check the current version). That page does not say how an online internship from an outside provider is treated, so do not assume that a CareerSwami internship counts toward that course. CareerSwami does not offer academic credit.
The university’s placement overview says the PAT cell starts training in the freshman year, covering resume building, coding training and mock interviews. Logging evidence fits those: a short resume line such as “added structured logging, request tracing and health checks to a Python API” is specific and checkable, and a failure walk-through is good mock-interview material.
One third-party document, a Scribd upload of 2021 report guidelines for a different programme (B.Tech CSE Gaming Technology), mentions a minimum of 4 weeks and a soft-copy report. It is not an official page and may be outdated, so treat it only as a hint that report formats and durations can vary by programme.
Verification steps for VIT Bhopal students
- Email your faculty coordinator or the PAT cell and ask in writing whether a 14-day online internship from an external provider is acceptable for your programme and year.
- Ask whether the 2-credit Internship course has a minimum duration, and keep the reply.
- Request the current internship report format and ask whether screenshots or log excerpts are allowed in the appendix.
- Ask what documents are needed (offer letter, completion certificate, mentor letter) and when they are due.
- Check with the PAT cell whether an internship must be arranged through the cell, or whether self-arranged ones are accepted.
- Save every answer as an email or a notice, not a verbal remark.
Frequently Asked Questions
Which Python logging library should I use for a short internship project?
Start with the standard logging module. It needs no installation, works with every framework and is enough for JSON output with a custom formatter. Libraries such as structlog or loguru are fine if your mentor prefers them, but they add learning time you may not have in 14 days.
Should I log to a file or to the console?
Console (standard output) is simplest and suits most hosting setups. Add a rotating file handler only if you need to keep logs locally for your report. Never let a log file grow unbounded.
What is the difference between a health check and a readiness check?
A health (liveness) check says the process is up. A readiness check also tests dependencies such as the database and returns 503 if one is unavailable. Having both lets you show the difference during a demo.
How much should I log at INFO level?
Enough to reconstruct what happened: one line per request plus key business events such as “user registered” or “payment recorded”. If INFO output is too noisy to read, move the detail to DEBUG.
Is it safe to log request bodies for debugging?
Not by default. Bodies often contain passwords or personal data. Log selected, non-sensitive fields instead, and mask anything that could identify a person.
Can I show logs in my demo if my app has no real users?
Yes. Generate requests with a script or API client, including deliberate failures, and show how the logs let you trace them. Say clearly that the traffic is test traffic.
Will logging and monitoring work count for my university internship credit?
That depends on VIT Bhopal’s rules for your programme, which are not stated on the pages linked above for online internships. Ask your coordinator or the PAT cell in writing, using the steps listed earlier.
Do I need a monitoring tool like Prometheus or Grafana?
Not for a 14-day project. Good logs and a health endpoint cover the essentials. If you finish early, a simple request counter exposed on a metrics endpoint is a reasonable extension to mention as future work.
Related Python & Backend Engineering guides
- Monad University Students: A Seven-Day Crash Plan Before a Backend Internship Starts
- Bhagwant University Students: Third-Party API Integration as a Backend Internship Task
- Shaheed Mahendra Karma Vishwavidyalaya Students: Backend Internship Applications With Limited Project Experience
- All Python & Backend Engineering internship guides
Ready to put this into practice?
Join the free two-week CareerSwami online internship in Python & Backend Engineering. The internship, the offer letter and the completion certificate are free.




















