-
Notifications
You must be signed in to change notification settings - Fork 77
日志配置详解
forgivedengkai edited this page Feb 5, 2020
·
2 revisions
目前fate-serving 使用log4j2作为日志组件,使用log4j2.xml来作为配置文件。
<Configuration status="ERROR" monitorInterval="60">
<Properties>
<Property name="logdir">logs</Property>
<Property name="project">fate</Property>
<Property name="module">serving-server</Property>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout charset="UTF-8"
pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} [%-5p] %c{1.}(%F:%L) - %m%n"/>
</Console>
<RollingFile name="info" fileName="${logdir}/${project}-${module}.log" filePattern="${logdir}/%d{yyyy-MM-dd}/${project}-${module}.log.%d{yyyy-MM-dd}">
<PatternLayout charset="UTF-8" pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} [%-5p] %c{1.}(%F:%L) - %m%n"/>
<Policies>
<TimeBasedTriggeringPolicy/>
</Policies>
<DefaultRolloverStrategy max="24"/>
</RollingFile>
<RollingFile name="flow" fileName="${logdir}/flow.log" filePattern="${logdir}/%d{yyyy-MM-dd}/flow.log.%d{yyyy-MM-dd}.log">
<PatternLayout charset="UTF-8" pattern="%d{yyyy-MM-dd HH:mm:ss,SSS}|%m%n"/>
<Policies>
<TimeBasedTriggeringPolicy/>
</Policies>
<DefaultRolloverStrategy max="24"/>
</RollingFile>
<RollingFile name="error" fileName="${logdir}/${project}-${module}-error.log" filePattern="${logdir}/${project}-${module}-error.log.%d{yyyy-MM-dd}.log">
<PatternLayout charset="UTF-8" pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} [%-5p] %c{1.}(%F:%L) - %m%n"/>
<Policies>
<TimeBasedTriggeringPolicy/>
</Policies>
<DefaultRolloverStrategy max="24"/>
</RollingFile>
</Appenders>
<Loggers>
<AsyncLogger name="flow" level="info" includeLocation="true" additivity="false">
<AppenderRef ref="flow"/>
</AsyncLogger>
<AsyncRoot level="info" includeLocation="true">
<AppenderRef ref="info" level="info"/>
<AppenderRef ref="error" level="error"/>
</AsyncRoot>
</Loggers>
</Configuration>
默认日志路径会打在启动目录的 logs文件夹中 日志文件有三个:
- fate-${module}.log
该日志为INFO日志,用于记录INFO级别日志,同时ERROR级别日志也会在其中体现
- fate-${module}-error.log
该日志为错误日志,用于记录error级别日志
- flow.log
该日志为访问日志,用于记录每一笔请求的到达时间、耗时、返回码、请求参数等