From 07ea220419103ac16c06a86d4e0790d5f14790a0 Mon Sep 17 00:00:00 2001 From: "zhaozhao.zz" Date: Tue, 23 May 2023 23:30:44 +0800 Subject: [PATCH] add a new loglevel 'nothing' to disable logging (#12133) Users can record logs of different levels by setting the `loglevel`. However, sometimes there are many logs even at the warning level, which can affect the performance of Redis. For example, when a user accesses the tls-port using a non-encrypted link, Redis will log lots of "# Error accepting a client connection: ...". We can provide the ability to disable logging so that users can temporarily turn off logging and turn it back on after the problem is resolved. --- redis.conf | 1 + src/config.c | 1 + src/server.h | 1 + 3 files changed, 3 insertions(+) diff --git a/redis.conf b/redis.conf index a58e46e5a..ee603b118 100644 --- a/redis.conf +++ b/redis.conf @@ -346,6 +346,7 @@ pidfile /var/run/redis_6379.pid # verbose (many rarely useful info, but not a mess like the debug level) # notice (moderately verbose, what you want in production probably) # warning (only very important / critical messages are logged) +# nothing (nothing is logged) loglevel notice # Specify the log file name. Also the empty string can be used to force diff --git a/src/config.c b/src/config.c index 6978cc5e7..36c2e42b7 100644 --- a/src/config.c +++ b/src/config.c @@ -79,6 +79,7 @@ configEnum loglevel_enum[] = { {"verbose", LL_VERBOSE}, {"notice", LL_NOTICE}, {"warning", LL_WARNING}, + {"nothing", LL_NOTHING}, {NULL,0} }; diff --git a/src/server.h b/src/server.h index e3f9c9729..c9a97966c 100644 --- a/src/server.h +++ b/src/server.h @@ -507,6 +507,7 @@ typedef enum { #define LL_VERBOSE 1 #define LL_NOTICE 2 #define LL_WARNING 3 +#define LL_NOTHING 4 #define LL_RAW (1<<10) /* Modifier to log without timestamp */ /* Supervision options */