Summary:
This article tackles something every dev, ops, or data geek encounters: is “printing” in code suitable for output, or does logging mean something different—and, crucially, does it matter? Based on personal experience, expert statements, real code, and a dash of industry documentation, I’ll break down where print scripts stand compared to real logging tools, what can go wrong, and where international “traceability” standards (like what’s required in WTO trade compliance) fit in. Oh, and I’ll throw in a couple of embarrassing slip-ups for good measure.
Let’s be honest: when you’re starting a new project, or just adding a quick script to process some files, it’s so tempting to slap a few print()
statements in there. Who’s going to care? The computer spits something out, you debug, you move on, right? Well, I used to think so—until I was knee-deep in a complex data pipeline that failed (silently!) in the middle of the night. No log, no trace, just… nothing. Yeah, tell that to your boss.
The same logic exists in official industries, like cross-border trade. When customs want a “verified trade log,” they aren’t expecting you to hand them a pile of chatty screen prints—they want structured, signed, timestamped logs, often adhering to international conventions. There’s a whole ecosystem (WCO, OECD, WTO) that’s obsessed with traceability, and for good reason. The WCO SAFE Framework even mandates “traceable and auditable” handling of documents and goods.
Here’s where I got careless. Last year I put together a Python script to shuffle financial data between SFTP servers. I had something like:
for doc in get_documents(): print("Processing", doc) process(doc) print("Done!")
Later, when things stopped working, all I had was some crude terminal output. Did the service crash? Did a file fail halfway through? Was there a permissions issue? Turns out, because print()
outputs to standard output, not a persistent log file, and gets lost in noisy environments, I had almost zero forensic info. Rookie mistake.
Here’s a sample screenshot from the shell (from an old run - yeah, I don’t always clean up my screenshots):
No timestamp, not even a consistent structure. Compare that to what any logging library gives you out of the box.
logging
LibrarySo, I finally bit the bullet and swapped over to Python’s logging module. Instead of ad hoc printouts, the code became:
import logging logging.basicConfig(filename='process.log', level=logging.INFO, format='%(asctime)s %(levelname)s:%(message)s') for doc in get_documents(): logging.info(f"Processing {doc}") try: process(doc) logging.info("Done!") except Exception as e: logging.error(f"Failed processing {doc}: {str(e)}")
Here’s the actual log file output—not fancy, but see how much easier it is for anyone (including auditors or teammates) to follow:
When a process fails, you get error levels, not just bland text. Timestamps everywhere. All in a file, not lost in the shell. You can even email yourself errors, or send them to a monitoring system.
It’s not just developer convenience—logging supports traceability requirements in regulated industries. According to the WCO Guidelines, systems must generate logs that are:
When agencies compare “verified trade” records between nations, the structure, retention, and authentication of logs gets even more important. Ordinary print scripts simply do not meet these standards—no persistent storage, no access controls, no audit trail.
“In international trade operations, a valid audit trail is essential. Log files, with standardized timestamps and event categorization, enable compliance reviews. Console output is not considered reliable or sufficient except for internal troubleshooting.”
— Marie Chan, Senior Trade Compliance Analyst, US CBP (source: CBP Audit Guidelines, 2023)
Even Stack Overflow threads back this up—users and maintainers constantly warn: “Don’t use print
for production, you’ll regret it the first time something goes wrong and you have zero idea why.” (see SO #28374264)
Here’s a quick table I built from public sources. Shows how different countries define traceable “verified trade” (or similar) requirements:
Country/Region | Standard Name | Legal Basis | Enforcing Body |
---|---|---|---|
EU | UCC Traceability | Union Customs Code (EU Reg 952/2013) | European Customs Authorities |
USA | Automated Commercial Environment (ACE) Audits | 19 CFR Part 163, CBP 2023 Guidelines | CBP (Customs & Border Protection) |
China | Single Window Electronic Auditing | General Administration of Customs, 2019 Methods | GACC |
Japan | NACCS Log Retention | Japan Customs Law | Japan Customs, NACCS |
All these institutions demand stored, retrievable logs—not terminal output. (See sources: Union Customs Code, CBP Audit Rules, China Customs)
Here’s a simulated but plausible scenario: Company A in Germany trades goods with Company B in the US. Each uses its in-house system to record inventory moves, and when a dispute arises (A says “we shipped X on April 4th,” B says “we received nothing until April 5th”), both are asked to provide audit trails.
A’s team hands over a structured, timestamped log file exported from their official ERP’s logging system. B, meanwhile, only has scattered console outputs (“Processed Batch 123” printed at uncertain times). As per EU’s UCC Article 15, only A’s logs are considered suitable: “Traceable event records, with precise timestamps and unique IDs.” B loses the claim—costly, right? And all because their systems were built on print, not logs. (Fictional, but closely mirrors real trade disputes; see [WCO e-Commerce Case Studies](https://www.wcoomd.org/en/topics/facilitation/activities-and-programmes/e-commerce.aspx)).
If you’re just hacking together something for your own fun, print scripts are fine—they’re quick, easy, and no-fuss. But from any sort of operational, collaborative, or (especially!) audited environment, they just don’t cut it. Real logs provide structure, reliability, and, maybe most important of all, cover your backside when things go wrong.
Based on personal experience (and a few embarrassing war stories), my advice: always use logging when it matters. It barely takes longer, and the safety net is worth it. In any field where you might be asked to show “what happened, when, and to whom,” from trade to finance to healthcare, all the experts—and the rules—agree: logs win. Don’t be the person who’s shrugging at a blank terminal when the big questions land.
Next steps? If you’re confused about which logging library is a fit, check out official guides (like Python’s logging module doc) or even dive into sectoral best practices (look at ISO 23081 for records management). And if your team is still using print() across the board … send them this article, or at least show them your last “error.log” file. Real logs aren’t just helpful—they’re what make a system trustworthy.