日志要记录什么:兼顾故障定位与敏感信息保护
让一条事件可以被解释
有效日志应该帮助回答何时发生了什么、涉及哪个对象、操作是否成功。常见字段包括事件时间、服务名称、请求标识、操作类型和结果代码。记录时间时保留时区,并确保相关服务器时钟同步,否则跨系统排查会因先后顺序错乱而受到影响。
请求标识可以把入口、业务处理和外部依赖中的相关记录连接起来。标识应具有足够区分度,但不应直接使用身份证号或访问令牌。异常记录还可以包含经过处理的错误类别与必要上下文,避免只留一句失败,也避免无选择地打印整个请求内容。
先决定哪些内容不能写入
密码、会话令牌、私钥和完整支付资料通常不应进入普通日志。对需要定位问题的个人信息,可采用遮盖或替代标识,并记录处理规则。脱敏应覆盖正常记录、异常堆栈和调试输出,不能仅在页面展示日志时才隐藏原始敏感字段。
不同日志可以设定不同保存期限。业务审计、系统故障和临时调试的用途各不相同,不宜全部无限期保留。确定期限时结合实际调查需求、容量和适用要求;到期处理也应覆盖归档副本,防止主系统删除后仍在其他位置长期保存。
确保需要时能够找到证据
集中保存有助于跨服务查询,但同时需要限制读取、下载和删除权限。对关键管理操作保留访问记录,避免任何运维人员都能随意改写全部历史。传输中断或磁盘接近容量上限时,应有明确提醒,不能等到事故发生后才发现记录缺了一整天。
定期选取一次真实业务流程,检查能否从日志重建其关键步骤,并验证时间、字段和检索条件是否一致。分析搜索引擎访问时,还应区分普通访问与经过来源验证的爬虫记录,单凭浏览器标识字符串不足以证明访问者身份。
(责任编辑:养护知识)
Trump demands probe into 'record setting error' after third-quarter GDP data gets massive revision higher
Nvidia reinstates Jensen Huang, Lululemon’s Chip Wilson sparks controversy and courting investors for Freedom Mobile: Must-read business and investing stories for the week of Nov. 28
Consider the company holiday party as work, so mind your booze
Upgraded
Iran reportedly used Starlink in military operations against U.S.
- Netflix将GPU可靠性视为分布式系统的问题
- Spain’s election could bring far right to power for first time in half a century
- Consider the company holiday party as work, so mind your booze
- Terrible, dangerous advice from the Ontario premier
- 给 AI 编码智能体装上知识库,反而更费 Token?JioHotstar 测完六种方案,文件搜索依然能打
- Draisaitl lifts Oilers past Kraken in overtime to snap five-game losing streak
- Adrian Morejon agrees to a $115-million, five-year deal with Blue Jays, source says
- Russia downs near-record number of drones as deaths mount in Ukraine
-
Walmart Promo Codes: 20% Off for November 2026
After living in big cities like San Francisco and New York, when I set foot in Wally World in the Mi...[详细]
-
Russia downs near-record number of drones as deaths mount in Ukraine
A woman looks through a window of a residential building damaged in a Russian airstrike in Zaporizhz...[详细]
-
Consider the company holiday party as work, so mind your booze
Listen to this article Learn more about audio Interested in more careers-related content? Check out ...[详细]
-
The Globe and Mail Listen to this article Learn more about audio Artificial intelligence chatbots ca...[详细]
-
Two Italians killed in Kuwait drone attack; Trump says Iran war ends ‘whenever I want it’
In this article Two Italians have been killed after an alleged Iranian attack on Kuwait, Kuwaiti for...[详细]
-
The Night Logan Woke Up runs at Tarragon Theatre in Toronto until Dec. 13. Jae Yang/Supplied Listen ...[详细]
-
The Globe and Mail Listen to this article Learn more about audio Artificial intelligence chatbots ca...[详细]
-
Hendrix Lapierre scores in OT as Penguins come back to beat Maple Leafs
Pittsburgh Penguins' Kris Letang (58) celebrates with Ville Koivunen (41) and Rutger McGroarty (2) a...[详细]
-
A month with the iPhone Duo has changed how I use my phone
For years, the definition of a premium smartphone depended on its cameras, processors, and how light...[详细]
-
Alberta isn’t planning to roll back abortion access but is looking into statistics, Smith says
Alberta Premier Danielle Smith addresses members at the United Conservative Party's annual general m...[详细]
What is ‘texture-maxxing’? The food trend putting crunch on the menu

By-election puts Brantford at the centre of Canada’s political universe

- Treasury's financial crimes agency says it's investigating 'cybersecurity incident'
- Middlefield’s Shane Obata loves a good monopoly
- Please put Dirty Dancing: The Musical back in its corner
- Protesters urge Quebec MNAs to reject oath to King
- The Best Herman Miller Black Friday Deals on Office Chairs, Desks, and More
- Register now: The Globe’s Art of the Story 2026 books event
- The high cost of a halfway approach to homelessness
