diff --git a/agent/logger/log.go b/agent/logger/log.go
index 75899c2fb2f..b1feaeb583b 100644
--- a/agent/logger/log.go
+++ b/agent/logger/log.go
@@ -86,9 +86,10 @@ func seelogConfig() string {
`
c += platformLogConfig()
c += `
-
- `
+ `
if Config.logfile != "" {
+ c += `
+ `
if Config.RolloverType == "size" {
c += `
`
}
+ c += `
+ `
}
c += `
-
diff --git a/agent/logger/log_unix_test.go b/agent/logger/log_unix_test.go
index 10455f256cf..b428ed1371e 100644
--- a/agent/logger/log_unix_test.go
+++ b/agent/logger/log_unix_test.go
@@ -52,6 +52,31 @@ func TestSeelogConfig_Default(t *testing.T) {
`, c)
}
+func TestSeelogConfig_WithotuLogFile(t *testing.T) {
+ Config = &logConfig{
+ driverLevel: DEFAULT_LOGLEVEL,
+ instanceLevel: DEFAULT_LOGLEVEL,
+ RolloverType: DEFAULT_ROLLOVER_TYPE,
+ outputFormat: DEFAULT_OUTPUT_FORMAT,
+ MaxFileSizeMB: DEFAULT_MAX_FILE_SIZE,
+ MaxRollCount: DEFAULT_MAX_ROLL_COUNT,
+ }
+ c := seelogConfig()
+ require.Equal(t, `
+
+
+
+
+
+
+
+
+
+
+
+`, c)
+}
+
func TestSeelogConfig_DebugLevel(t *testing.T) {
Config = &logConfig{
logfile: "foo.log",
diff --git a/agent/logger/log_windows_test.go b/agent/logger/log_windows_test.go
index 608b55d3103..46dfda49881 100644
--- a/agent/logger/log_windows_test.go
+++ b/agent/logger/log_windows_test.go
@@ -53,6 +53,33 @@ func TestSeelogConfigWindows_Default(t *testing.T) {
`, c)
}
+func TestSeelogConfigWindows_WithoutLogFile(t *testing.T) {
+ Config = &logConfig{
+ logfile: "foo.log",
+ driverLevel: DEFAULT_LOGLEVEL,
+ instanceLevel: DEFAULT_LOGLEVEL,
+ RolloverType: DEFAULT_ROLLOVER_TYPE,
+ outputFormat: DEFAULT_OUTPUT_FORMAT,
+ MaxFileSizeMB: DEFAULT_MAX_FILE_SIZE,
+ MaxRollCount: DEFAULT_MAX_ROLL_COUNT,
+ }
+ c := seelogConfig()
+ require.Equal(t, `
+
+
+
+
+
+
+
+
+
+
+
+
+`, c)
+}
+
func TestSeelogConfigWindows_DebugLevel(t *testing.T) {
Config = &logConfig{
logfile: "foo.log",