Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Parameter 'log-file-path' does not take effect #6467

Open
msun1996 opened this issue Mar 1, 2024 · 2 comments
Open

[Bug] Parameter 'log-file-path' does not take effect #6467

msun1996 opened this issue Mar 1, 2024 · 2 comments
Assignees

Comments

@msun1996
Copy link
Contributor

msun1996 commented Mar 1, 2024

Describe the bug
Parameter log-file-path does not take effect

To Reproduce
manager --log-file-path=/export/logs/vela.log ...
You will find that the log has been output to the console, and the log has not been created and output to the file /export/logs/vela.log

Expected behavior
Log parameters such as log-file-path, log-file-max-size, log-debug can take effect normally

Screenshots

KubeVela Version
1.9.2

Cluster information
1.19

Additional context

Troubleshooting reasons:

func (s *CoreOptions) Flags() cliflag.NamedFlagSets {
        fss := cliflag.NamedFlagSets{}
	gfs := fss.FlagSet("generic")
	gfs.StringVar(&s.LogFilePath, "log-file-path", s.LogFilePath, "The file to write logs to.")
	gfs.Uint64Var(&s.LogFileMaxSize, "log-file-max-size", s.LogFileMaxSize, "Defines the maximum size a log file can grow to, Unit is megabytes.")
	gfs.BoolVar(&s.LogDebug, "log-debug", s.LogDebug, "Enable debug logs for development purpose")
	kfs := fss.FlagSet("klog")
	utillog.AddFlags(kfs)

	if s.LogDebug {
		_ = kfs.Set("v", strconv.Itoa(int(commonconfig.LogDebug)))
	}

	if s.LogFilePath != "" {
		_ = kfs.Set("logtostderr", "false")
		_ = kfs.Set("log_file", s.LogFilePath)
		_ = kfs.Set("log_file_max_size", strconv.FormatUint(s.LogFileMaxSize, 10))
	}
}

As implemented above, in the Flags configuration phase, s.LogFilePath must be the default empty string. Therefore, the log configuration will not take effect in klog.

Solution:
Log configuration and flush moved to run function
image

@EraKin575
Copy link

Hi! I would like to work on this issue

@EraKin575
Copy link

/assign

msun1996 pushed a commit to msun1996/kubevela that referenced this issue May 27, 2024
Signed-off-by: hanzhaoyang <hanzhaoyang@jd.com>
msun1996 pushed a commit to msun1996/kubevela that referenced this issue May 28, 2024
Signed-off-by: hanzhaoyang <hanzhaoyang@jd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants