LogFilter
一款高度可配置的 Minecraft 日志过滤模组。屏蔽嘈杂的日志消息,突出显示重要内容,并保持控制台整洁,所有这些都支持热重载规则。
Wiki:
功能
- 正则表达式消息过滤:使用正则表达式匹配并屏蔽基于内容的日志消息
- Logger 名称过滤:按确切的 logger 名称或正则表达式模式进行过滤,支持层级匹配
- 日志级别过滤:针对特定的日志级别(DEBUG、INFO、WARN、ERROR)
- 过滤操作:每条规则可设置为 DENY(屏蔽)、ALLOW(强制显示)或 NEUTRAL(放行)
- 单条规则启用/禁用:在不删除规则的情况下切换各个规则的开关
- 热重载:编辑
logfilter.json 后更改立即生效,无需重启
- 包含默认规则:附带预制的(默认禁用)规则,用于处理常见的日志垃圾信息
配置
LogFilter 将其配置存储在 Minecraft 配置目录中的 logfilter.json 文件中。首次启动时会自动创建该文件,并包含合理的默认值。
示例配置
{
"configVersion": 1,
"enabled": true,
"rules": [
{
"name": "Suppress OpenAL spam",
"enabled": true,
"type": "MESSAGE_REGEX",
"pattern": "(?i)openal",
"action": "DENY",
"level": null
},
{
"name": "Block debug logs from server level",
"enabled": true,
"type": "LOGGER_NAME",
"pattern": "net.minecraft.server.level",
"action": "DENY",
"level": "DEBUG"
},
{
"name": "Always show errors",
"enabled": true,
"type": "LEVEL",
"pattern": "ERROR",
"action": "ALLOW",
"level": null
}
]
}
规则类型
| Type |
Description |
MESSAGE_REGEX |
将日志消息内容与正则表达式模式进行匹配 |
LOGGER_NAME |
通过确切的 logger 名称或前缀(层级结构)进行匹配 |
LOGGER_REGEX |
使用正则表达式模式匹配 logger 名称 |
LEVEL |
按日志级别(DEBUG、INFO、WARN、ERROR)进行匹配 |
操作
| Action |
Description |
DENY |
屏蔽日志消息 |
ALLOW |
强制消息通过,无视其他规则 |
NEUTRAL |
无效果,将消息传递到下一条规则 |
可选的级别限制
任何规则都可以包含一个 level 字段以将其限制为特定的日志级别。例如,带有 "level": "DEBUG" 的 LOGGER_NAME 规则将仅匹配来自该 logger 的调试消息。
默认规则
LogFilter 附带几个预配置的规则(默认禁用),助你快速上手:
- 屏蔽 OpenAL/LWJGL 的信息垃圾消息
- 屏蔽进度加载消息
- 屏蔽来自
net.minecraft.server.level 的调试日志
- 屏蔽配方加载消息
- 始终允许 ERROR 级别的消息
通过在配置文件中设置 "enabled": true 来启用它们。
LogFilter
A highly configurable log filtering mod for Minecraft. Suppress noisy log messages, highlight important ones, and keep your console clean, all with hot-reloadable rules.
Wiki:
Features
- Regex message filtering: Match and suppress log messages by content using regular expressions
- Logger name filtering: Filter by exact logger name or regex pattern, with hierarchical matching
- Log level filtering: Target specific log levels (DEBUG, INFO, WARN, ERROR)
- Filter actions: DENY (suppress), ALLOW (force show), or NEUTRAL (pass through) per rule
- Per-rule enable/disable: Toggle individual rules without removing them
- Hot-reload: Edit
logfilter.json and changes apply instantly, no restart needed
- Default rules included: Ships with pre-made (disabled) rules for common log spam
Configuration
LogFilter stores its config in logfilter.json in your Minecraft config directory. The file is created automatically on first launch with sensible defaults.
Example Config
{
"configVersion": 1,
"enabled": true,
"rules": [
{
"name": "Suppress OpenAL spam",
"enabled": true,
"type": "MESSAGE_REGEX",
"pattern": "(?i)openal",
"action": "DENY",
"level": null
},
{
"name": "Block debug logs from server level",
"enabled": true,
"type": "LOGGER_NAME",
"pattern": "net.minecraft.server.level",
"action": "DENY",
"level": "DEBUG"
},
{
"name": "Always show errors",
"enabled": true,
"type": "LEVEL",
"pattern": "ERROR",
"action": "ALLOW",
"level": null
}
]
}
Rule Types
| Type |
Description |
MESSAGE_REGEX |
Match the log message content against a regex pattern |
LOGGER_NAME |
Match by exact logger name or prefix (hierarchical) |
LOGGER_REGEX |
Match logger names using a regex pattern |
LEVEL |
Match by log level (DEBUG, INFO, WARN, ERROR) |
Actions
| Action |
Description |
DENY |
Suppress the log message |
ALLOW |
Force the message through, regardless of other rules |
NEUTRAL |
No effect, pass through to the next rule |
Optional Level Restriction
Any rule can include a level field to restrict it to a specific log level. For example, a LOGGER_NAME rule with "level": "DEBUG" will only match debug messages from that logger.
Default Rules
LogFilter ships with several pre-configured rules (disabled by default) to get you started:
- Suppress OpenAL/LWJGL info spam
- Suppress advancement loading messages
- Suppress debug logs from
net.minecraft.server.level
- Suppress recipe loading messages
- Always allow ERROR-level messages
Enable them by setting "enabled": true in the config file.
评论 0
登录后参与评分
还没有评论,来抢沙发吧