From d7e60c65d6e919638905917d48cd0bccad3eee83 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sun, 6 Jun 2021 22:10:03 +0800 Subject: [PATCH] file log path supports relative path --- Dockerfile | 2 +- conf/ezbookkeeping.ini | 2 +- pkg/settings/setting.go | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index c3b66c7e..4916e93c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ COPY docker/docker-entrypoint.sh /docker-entrypoint.sh RUN chmod +x /docker-entrypoint.sh RUN mkdir -p /usr/local/bin/ezbookkeeping && chown 1000:1000 /usr/local/bin/ezbookkeeping \ && mkdir -p /usr/local/bin/ezbookkeeping/data && chown 1000:1000 /usr/local/bin/ezbookkeeping/data \ - && mkdir -p /var/log/ezbookkeeping && chown 1000:1000 /var/log/ezbookkeeping + && mkdir -p /usr/local/bin/ezbookkeeping/log && chown 1000:1000 /usr/local/bin/ezbookkeeping/log WORKDIR /usr/local/bin/ezbookkeeping COPY --from=be-builder --chown=1000:1000 /go/src/github.com/mayswind/ezbookkeeping/ezbookkeeping /usr/local/bin/ezbookkeeping/ezbookkeeping COPY --from=fe-builder --chown=1000:1000 /go/src/github.com/mayswind/ezbookkeeping/dist /usr/local/bin/ezbookkeeping/public diff --git a/conf/ezbookkeeping.ini b/conf/ezbookkeeping.ini index c8b18b80..43c844d5 100644 --- a/conf/ezbookkeeping.ini +++ b/conf/ezbookkeeping.ini @@ -77,7 +77,7 @@ mode = console file level = info # For "file" only, absolute path of log file -log_path = /var/log/ezbookkeeping/ezbookkeeping.log +log_path = log/ezbookkeeping.log [uuid] # Uuid generator type, supports "internal" currently diff --git a/pkg/settings/setting.go b/pkg/settings/setting.go index 049ca2f7..076b9148 100644 --- a/pkg/settings/setting.go +++ b/pkg/settings/setting.go @@ -368,7 +368,9 @@ func loadLogConfiguration(config *Config, configFile *ini.File, sectionName stri config.LogLevel = getLogLevel(getConfigItemStringValue(configFile, sectionName, "level"), defaultLoglevel) if config.EnableFileLog { - config.FileLogPath = getConfigItemStringValue(configFile, sectionName, "log_path") + fileLogPath := getConfigItemStringValue(configFile, sectionName, "log_path") + finalFileLogPath, _ := getFinalPath(config.WorkingPath, fileLogPath) + config.FileLogPath = finalFileLogPath } return nil