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

Can't set log level in DaemonBase #21361

Open
ZhaohuiS opened this issue Jan 9, 2025 · 0 comments
Open

Can't set log level in DaemonBase #21361

ZhaohuiS opened this issue Jan 9, 2025 · 0 comments
Assignees
Labels
MSFT Triaged this issue has been triaged

Comments

@ZhaohuiS
Copy link
Contributor

ZhaohuiS commented Jan 9, 2025

Description

Can't set log level in DaemonBase
Only NOTICE the default level can be printed into syslog

Steps to reproduce the issue:

script 1:

from sonic_py_common import daemon_base
SYSLOG_IDENTIFIER = "TestSysLogger"
log3 = daemon_base.DaemonBase(SYSLOG_IDENTIFIER, use_syslogger=True)
log3.set_min_log_priority_debug()

log3.log_info("log3: This is a info message")
log3.log_notice("log3: This is a notice message")
log3.log_warning("log3: This is a warning message")
log3.log_debug("log3: This is a debug message")
log3.log_error("log3: This is a error message")

log3.log_info("log3: This is a info message, console", also_print_to_console=True)
log3.log_notice("log3: This is a notice message, console", also_print_to_console=True)
log3.log_warning("log3: This is a warning message,console", also_print_to_console=True)
log3.log_debug("log3: This is a debug message,console", also_print_to_console=True)
log3.log_error("log3: This is a error message,consle", also_print_to_console=True)

console output 1:

log3: This is a info message, console
log3: This is a notice message, console
log3: This is a warning message,console
log3: This is a debug message,console
log3: This is a error message,consle

syslog output 1:

2025 Jan  9 04:28:28.943065 bjw-can-7260-8 NOTICE TestSysLogger[1112399]: log3: This is a notice message
2025 Jan  9 04:28:28.943233 bjw-can-7260-8 WARNING TestSysLogger[1112399]: log3: This is a warning message
2025 Jan  9 04:28:28.943311 bjw-can-7260-8 ERR TestSysLogger[1112399]: log3: This is a error message
2025 Jan  9 04:28:28.943406 bjw-can-7260-8 NOTICE TestSysLogger[1112399]: log3: This is a notice message, console
2025 Jan  9 04:28:28.943475 bjw-can-7260-8 WARNING TestSysLogger[1112399]: log3: This is a warning message,console
2025 Jan  9 04:28:28.943544 bjw-can-7260-8 ERR TestSysLogger[1112399]: log3: This is a error message,consle

No INFO and DEBUG log

script 2:

from sonic_py_common import daemon_base
SYSLOG_IDENTIFIER = "TestSysLogger"
log3 = daemon_base.DaemonBase(SYSLOG_IDENTIFIER, use_syslogger=False)
log3.set_min_log_priority_debug()

log3.log_info("log3: This is a info message")
log3.log_notice("log3: This is a notice message")
log3.log_warning("log3: This is a warning message")
log3.log_debug("log3: This is a debug message")
log3.log_error("log3: This is a error message")

log3.log_info("log3: This is a info message, console", also_print_to_console=True)
log3.log_notice("log3: This is a notice message, console", also_print_to_console=True)
log3.log_warning("log3: This is a warning message,console", also_print_to_console=True)
log3.log_debug("log3: This is a debug message,console", also_print_to_console=True)
log3.log_error("log3: This is a error message,consle", also_print_to_console=True)

console output 2:

log3: This is a notice message, console
log3: This is a warning message,console
log3: This is a error message,consle

syslog output 2:

2025 Jan  9 04:31:20.918889 bjw-can-7260-8 NOTICE TestSysLogger[1114066]: log3: This is a notice message
2025 Jan  9 04:31:20.919058 bjw-can-7260-8 WARNING TestSysLogger[1114066]: log3: This is a warning message
2025 Jan  9 04:31:20.919134 bjw-can-7260-8 ERR TestSysLogger[1114066]: log3: This is a error message
2025 Jan  9 04:31:20.919213 bjw-can-7260-8 NOTICE TestSysLogger[1114066]: log3: This is a notice message, console
2025 Jan  9 04:31:20.919287 bjw-can-7260-8 WARNING TestSysLogger[1114066]: log3: This is a warning message,console
2025 Jan  9 04:31:20.919353 bjw-can-7260-8 ERR TestSysLogger[1114066]: log3: This is a error message,consle

No INFO and DEBUG log

More details in #21291

Describe the results you received:

INFO and DEBUG logs can't be printed into syslog
no way to set level info in deamon_base.py so far, the default level is NOTICE

Describe the results you expected:

We can control log level in daemon_base.py

Output of show version:

(paste your output here)

Output of show techsupport:

(paste your output here or download and attach the file here )

Additional information you deem important (e.g. issue happens only occasionally):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MSFT Triaged this issue has been triaged
Projects
None yet
Development

No branches or pull requests

2 participants