用 wevtutil 在命令行筛选事件日志

不打开事件查看器,直接查询 System 或 Application 日志中的最新错误。

Windows命令提示符诊断事件日志低风险
运行 `wevtutil qe System /q:"*[System[(Level=2)]]" /c:20 /rd:true /f:text` 查看最近 20 条 System 日志错误。

01命令

命令
$ wevtutil qe System /q:"*[System[(Level=2)]]" /c:20 /rd:true /f:text

02作用说明

wevtutil qe 通过 XPath 过滤器查询事件通道;Level=2 表示错误事件,/rd:true 表示按最新优先排列。把通道名改为 Application 或 Security 即可切换日志,也可以把条件写成 (Level=1 or Level=2) 来同时包含严重错误。这个命令容易被忘记,是因为 XPath 过滤器需要引号包裹且括号内区分大小写。

03风险

风险低风险
使用条件Administrator privileges for some logs such as Security
!注意: /q 过滤器必须按原样用引号包裹,否则 XML 括号会被 shell 错误解析。

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • wevtutil - Windows Commands
    Microsoft Learn · vendor-doc · 2026-09-17
    依据: Documents wevtutil, including the query-events (qe) command with /q XPath filter, /c count, /rd reverse direction and /f text format.

最后验证: 2026-09-17 · 分类: 系统与设置

06相关方案