16.3.2. 设置日志记录格式
要为日志记录行设置日志记录格式,请执行以下步骤:
- 使用上表构建所需的格式模板。
输入以下命令:
bin/kc.[sh|bat] start --log-console-format="'<format>'"
请注意,在使用 CLI 中调用包含特殊 shell 字符(如 )的命令时,您需要转义字符。 因此,请考虑在配置文件中设置它。
示例:缩写完全限定类别名称
bin/kc.[sh|bat] start --log-console-format="'%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c{3.}] (%t) %s%e%n'"
本例通过将类别名称缩写为三个字符,方法是在模板中设置 [%c{3.}],而不是默认的 [%c]。