Skip to content
C

Configured File Logger

Mediumpython

Configure logging to write to a file app.log (without a timestamp in the format, so the output stays exactly reproducible), then log one message at each of the 5 severity levels, and print back what actually landed in the file.

Why no timestamp? including %(asctime)s would make the file's content different every time it runs (down to the millisecond), which an exact-match judge can never grade — so this problem uses a format of just the level name and the message, which the notes themselves show is fully configurable.

Approach: logging.basicConfig(filename="app.log", level=<threshold>, format="%(levelname)s - %(message)s"), log one message at each level, then read the file back and print its contents — only messages at or above the configured threshold should actually appear.

Input: One line: the threshold level name (one of DEBUG, INFO, WARNING, ERROR, CRITICAL).

Output: The contents of app.log — one line per message at or above the given threshold, in level order.

Input (stdin)

Output

Run your code to see output here...