Skip to content

Commit 76eef7f

Browse files
lvan100lianghuan
authored andcommitted
111
1 parent 8e820e3 commit 76eef7f

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

gs/log.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,25 @@ func initLog() error {
4747
return util.FormatError(err, "bind error in source sys")
4848
}
4949

50-
var (
51-
logFileDefault = filepath.Join(c.LocalDir, "log.xml")
52-
logFileProfile string
53-
)
50+
extensions := []string{".properties", ".yaml", ".yml", ".xml", ".json"}
51+
52+
var files []string
53+
for _, ext := range extensions {
54+
files = append(files, filepath.Join(c.LocalDir, "log"+ext))
55+
}
5456

55-
// If one or more profiles are set, use the first profile to look
56-
// for a profile-specific log configuration file.
5757
if c.Profiles != "" {
58-
profile := strings.Split(c.Profiles, ",")[0]
59-
logFileProfile = filepath.Join(c.LocalDir, "log-"+profile+".xml")
58+
profile := strings.TrimSpace(strings.Split(c.Profiles, ",")[0])
59+
if profile != "" {
60+
for _, ext := range extensions {
61+
files = append(files, filepath.Join(c.LocalDir, "log-"+profile+ext))
62+
}
63+
}
6064
}
6165

6266
// Determine which log configuration file to use.
6367
var logFile string
64-
for _, s := range []string{logFileProfile, logFileDefault} {
68+
for _, s := range files {
6569
if ok, err := util.PathExists(s); err != nil {
6670
return err
6771
} else if !ok {

0 commit comments

Comments
 (0)