[Improvement] not print logs to fe.out when fe is running under daemon mode (#9195)
Co-authored-by: yiguolei <yiguolei@gmail.com>
This commit is contained in:
@ -22,7 +22,7 @@ namespace doris {
|
||||
|
||||
// ErrorName, ErrorCode, String Description, Should print stacktrace
|
||||
#define APPLY_FOR_ERROR_CODES(M) \
|
||||
M(OLAP_SUCCESS, 0, "", true) \
|
||||
M(OLAP_SUCCESS, 0, "", false) \
|
||||
M(OLAP_ERR_OTHER_ERROR, -1, "", true) \
|
||||
M(OLAP_REQUEST_FAILED, -2, "", true) \
|
||||
M(OLAP_ERR_OS_ERROR, -100, "", true) \
|
||||
|
||||
@ -180,6 +180,7 @@ if [ ${IMAGE_TOOL} -eq 1 ]; then
|
||||
elif [ ${RUN_DAEMON} -eq 1 ]; then
|
||||
nohup $LIMIT $JAVA $final_java_opt org.apache.doris.PaloFe ${HELPER} "$@" >> $LOG_DIR/fe.out 2>&1 < /dev/null &
|
||||
else
|
||||
export DORIS_LOG_TO_STDERR=1
|
||||
$LIMIT $JAVA $final_java_opt org.apache.doris.PaloFe ${HELPER} "$@" < /dev/null
|
||||
fi
|
||||
|
||||
|
||||
@ -66,6 +66,9 @@ public class PaloFe {
|
||||
|
||||
// entrance for doris frontend
|
||||
public static void start(String dorisHomeDir, String pidDir, String[] args) {
|
||||
if (System.getenv("DORIS_LOG_TO_STDERR") != null) {
|
||||
Log4jConfig.foreground = true;
|
||||
}
|
||||
if (Strings.isNullOrEmpty(dorisHomeDir)) {
|
||||
System.err.println("env DORIS_HOME is not set.");
|
||||
return;
|
||||
|
||||
@ -97,7 +97,7 @@ public class Log4jConfig extends XmlConfiguration {
|
||||
" <Root level=\"${sys_log_level}\">\n" +
|
||||
" <AppenderRef ref=\"Sys\"/>\n" +
|
||||
" <AppenderRef ref=\"SysWF\" level=\"WARN\"/>\n" +
|
||||
" <AppenderRef ref=\"Console\"/>\n" +
|
||||
" <!--REPLACED BY Console Logger-->\n" +
|
||||
" </Root>\n" +
|
||||
" <Logger name=\"audit\" level=\"ERROR\" additivity=\"false\">\n" +
|
||||
" <AppenderRef ref=\"Auditfile\"/>\n" +
|
||||
@ -116,6 +116,12 @@ public class Log4jConfig extends XmlConfiguration {
|
||||
public static String confDir;
|
||||
// custom conf dir
|
||||
public static String customConfDir;
|
||||
// Doris uses both system.out and log4j to print log messages.
|
||||
// This variable is used to check whether to add console appender to loggers.
|
||||
// If doris is running under daemon mode, then this variable == false, and console logger will not be added.
|
||||
// If doris is not running under daemon mode, then this variable == true, and console logger will be added to
|
||||
// loggers, all logs will be printed to console.
|
||||
public static boolean foreground = false;
|
||||
|
||||
private static void reconfig() throws IOException {
|
||||
String newXmlConfTemplate = xmlConfTemplate;
|
||||
@ -167,6 +173,12 @@ public class Log4jConfig extends XmlConfiguration {
|
||||
newXmlConfTemplate = newXmlConfTemplate.replaceAll("<!--REPLACED BY AUDIT AND VERBOSE MODULE NAMES-->",
|
||||
sb.toString());
|
||||
|
||||
if (foreground) {
|
||||
StringBuilder consoleLogger = new StringBuilder();
|
||||
consoleLogger.append("<AppenderRef ref=\"Console\"/>\n");
|
||||
newXmlConfTemplate = newXmlConfTemplate.replaceAll("<!--REPLACED BY Console Logger-->",
|
||||
consoleLogger.toString());
|
||||
}
|
||||
Map<String, String> properties = Maps.newHashMap();
|
||||
properties.put("sys_log_dir", sysLogDir);
|
||||
properties.put("sys_file_pattern", sysLogRollPattern);
|
||||
|
||||
Reference in New Issue
Block a user