Skip to content

Commit

Permalink
[fix](log4j) fix some issues when modify log config (#21099)
Browse files Browse the repository at this point in the history
Co-authored-by: caiconghui1 <caiconghui1@jd.com>
  • Loading branch information
2 people authored and xiaokang committed Jul 3, 2023
1 parent 76a8c9c commit 4296058
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class Log4jConfig extends XmlConfiguration {
+ " <Pattern>%d{yyyy-MM-dd HH:mm:ss,SSS} %p (%t|%tid)<!--REPLACED BY LOG FORMAT-->%m%n</Pattern>\n"
+ " </PatternLayout>\n"
+ " </Console>"
+ " <RollingFile name=\"Sys\" fileName=\"${sys_log_dir}/fe.log\" filePattern=\"${sys_log_dir}/fe.log.${sys_file_pattern}-%i\">\n"
+ " <RollingFile name=\"Sys\" fileName=\"${sys_log_dir}/fe.log\" filePattern=\"${sys_log_dir}/fe.log.${sys_file_pattern}-%i\" immediateFlush=\"${immediate_flush_flag}\">\n"
+ " <PatternLayout charset=\"UTF-8\">\n"
+ " <Pattern>%d{yyyy-MM-dd HH:mm:ss,SSS} %p (%t|%tid)<!--REPLACED BY LOG FORMAT-->%m%n</Pattern>\n"
+ " </PatternLayout>\n"
Expand All @@ -62,7 +62,7 @@ public class Log4jConfig extends XmlConfiguration {
+ " </Delete>\n"
+ " </DefaultRolloverStrategy>\n"
+ " </RollingFile>\n"
+ " <RollingFile name=\"SysWF\" fileName=\"${sys_log_dir}/fe.warn.log\" filePattern=\"${sys_log_dir}/fe.warn.log.${sys_file_pattern}-%i\">\n"
+ " <RollingFile name=\"SysWF\" fileName=\"${sys_log_dir}/fe.warn.log\" filePattern=\"${sys_log_dir}/fe.warn.log.${sys_file_pattern}-%i\" immediateFlush=\"${immediate_flush_flag}\">\n"
+ " <PatternLayout charset=\"UTF-8\">\n"
+ " <Pattern>%d{yyyy-MM-dd HH:mm:ss,SSS} %p (%t|%tid)<!--REPLACED BY LOG FORMAT-->%m%n</Pattern>\n"
+ " </PatternLayout>\n"
Expand Down Expand Up @@ -94,7 +94,7 @@ public class Log4jConfig extends XmlConfiguration {
+ " </RollingFile>\n"
+ " </Appenders>\n"
+ " <Loggers>\n"
+ " <Root level=\"${sys_log_level}\" includeLocation=\"${include_location_flag}\" immediateFlush=\"${immediate_flush_flag}\">\n"
+ " <Root level=\"${sys_log_level}\" includeLocation=\"${include_location_flag}\">\n"
+ " <AppenderRef ref=\"Sys\"/>\n"
+ " <AppenderRef ref=\"SysWF\" level=\"WARN\"/>\n"
+ " <!--REPLACED BY Console Logger-->\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private void appendLogConf(Map<String, Map<String, String>> content) {
}
if (!Strings.isNullOrEmpty(delVerboseName)) {
delVerboseName = delVerboseName.trim();
List<String> verboseNames = Lists.newArrayList(configs.y);
List<String> verboseNames = Lists.newArrayList(configs.z);
if (verboseNames.contains(delVerboseName)) {
verboseNames.remove(delVerboseName);
configs = Log4jConfig.updateLogging(null, null,
Expand All @@ -100,8 +100,9 @@ private void appendLogConf(Map<String, Map<String, String>> content) {
}

map.put("Level", configs.x);
map.put("VerboseNames", StringUtils.join(configs.y, ","));
map.put("AuditNames", StringUtils.join(configs.z, ","));
map.put("Mode", configs.y);
map.put("VerboseNames", StringUtils.join(configs.z, ","));
map.put("AuditNames", StringUtils.join(configs.u, ","));
content.put("LogConfiguration", map);
} catch (IOException e) {
LOG.error(e);
Expand Down
3 changes: 2 additions & 1 deletion ui/src/pages/logs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export default function Logs(params: any) {
<Typography style={{padding: '30px'}}>
<Title>Log Configuration</Title>
<Paragraph>
<p>Level: {LogConfiguration.VerboseNames}</p>
<p>Level: {LogConfiguration.Level}</p>
<p>Mode: {LogConfiguration.Mode}</p>
<p>Verbose Names:{LogConfiguration.VerboseNames}</p>
<p>Audit Names: {LogConfiguration.AuditNames}</p>
</Paragraph>
Expand Down

0 comments on commit 4296058

Please sign in to comment.