Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

应用日志优化建议

未关闭
#238 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
java

调研方向

Start by tracing the three proposed entry points: the global /** HTTP interceptor, KeyCallable for asynchronous MDC context, and CacheBaseJob.execute for Quartz jobs. Review how MDC and TransIdUtils are currently used, then define a focused scope and acceptance checks for correlating related logs without losing context across threads or scheduled tasks.

由索引模型根据 Issue 内容生成。

描述

由于项目采取大量的异步线程池执行,所以说一个流程的日志散落到了多行,线上出现异常的时候不好定位问题,建议给每个流程添加一个追踪id,用于在出现异常时能很快把相关日志全部查出,暂时看到了三个切入点:
1.http请求可添加一个全局的/**的拦截器
MDC.put("TansId", TransIdUtils.generateDateTimeInnerTransId());
2.异步线程池mdc跟踪,KeyCallable中添加变量mdc上下文内容
private final Map<String, String> logContextMap;
logContextMap = MDC.getCopyOfContextMap();
if (this.logContextMap != null) { MDC.setContextMap(this.logContextMap); }
3.quartz定时任务,CacheBaseJob的excute函数中添加追踪id
MDC.put("TansId", TransIdUtils.generateDateTimeInnerTransId());
4.应用日志异步打印,实时刷盘会局限于磁盘io性能
5.日志格式、存放路径之类的可配置化

主要语言
HTML
星标
9k
派生
2k
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

sohutv/cachecloud 的其他 Issue

查看 sohutv/cachecloud 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。