]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1893844: configurable logging with a sensible default (#126)
authorDave Miller <justdave@bugzilla.org>
Sun, 28 Apr 2024 05:54:14 +0000 (01:54 -0400)
committerGitHub <noreply@github.com>
Sun, 28 Apr 2024 05:54:14 +0000 (01:54 -0400)
* Adds a localconfig var called "logging_method" which points at a config file in the conf directory (which config file to use, there are several that preconfigure log4perl to log various different ways).
* Set the default to syslog.

Bugzilla/Install/Localconfig.pm
Bugzilla/Logging.pm
Bugzilla/Util.pm
RELEASE_BLOCKERS.md
conf/log4perl-file.conf [moved from conf/log4perl-default.conf with 100% similarity]
conf/log4perl-syslog.conf
template/en/default/setup/strings.txt.pl

index 4a19b2c3611081dcc0569dc6cad06a89b9ed5e44..ee08842eea15707e93a378706dc36e3c0aff03cb 100644 (file)
@@ -102,6 +102,7 @@ use constant LOCALCONFIG_VARS => (
   {name => 'memcached_namespace', default => "bugzilla:",},
   {name => 'urlbase',             default => '',},
   {name => 'canonical_urlbase',   lazy => 1},
+  {name => 'logging_method',      default => 'syslog'},
   {name => 'nobody_user',         default => 'nobody@mozilla.org'},
   {name => 'attachment_base',     default => '',},
   {name => 'ses_username',        default => '',},
index 870214207fe4c3c86ee1f0940382f6a913bed557..9a68e51ee268281fbb9033869212e71d98296b9a 100644 (file)
@@ -14,6 +14,7 @@ use Log::Log4perl qw(:easy);
 use Log::Log4perl::MDC;
 use File::Spec::Functions qw(rel2abs catfile);
 use Bugzilla::Constants qw(bz_locations);
+use Bugzilla::Install::Localconfig;
 use English qw(-no_match_vars $PROGRAM_NAME);
 
 sub logfile {
@@ -28,7 +29,10 @@ sub fields {
 }
 
 BEGIN {
-  my $file = $ENV{LOG4PERL_CONFIG_FILE} // 'log4perl-default.conf';
+  my $lc = Bugzilla::Install::Localconfig::read_localconfig();
+  # Use the environment variable if it exists, otherwise use the value
+  # from localconfig, or if that's not set, use syslog.
+  my $file = $ENV{LOG4PERL_CONFIG_FILE} // ("log4perl-" . ($lc->{'logging_method'} // 'syslog') . ".conf");
   Log::Log4perl::Logger::create_custom_level('NOTICE', 'WARN', 5, 2);
   Log::Log4perl->init(rel2abs($file, bz_locations->{confdir}));
   TRACE("logging enabled in $PROGRAM_NAME");
index 14d3311f865fbd15055a1c9eb2a48a13df5872bb..2284cf8cabd3e43f13fe06afdb4389b4884b5a77 100644 (file)
@@ -29,7 +29,8 @@ use base qw(Exporter);
   get_text template_var disable_utf8
   enable_utf8 detect_encoding email_filter
   round extract_nicks);
-use Bugzilla::Logging;
+# Bugzilla::Logging cannot be used it this file due to circular dependency
+#use Bugzilla::Logging;
 use Bugzilla::Constants;
 use Bugzilla::RNG qw(irand);
 
@@ -329,7 +330,6 @@ sub do_ssl_redirect_if_required {
 
   # If we're already running under SSL, never redirect.
   return if $ENV{HTTPS} && $ENV{HTTPS} eq 'on';
-  DEBUG("Redirect to HTTPS because \$ENV{HTTPS}=$ENV{HTTPS}");
   Bugzilla->cgi->redirect_to_https();
 }
 
index a14c3cb6aa90f2c3d8a0b104c63e8689b1499bc9..dbd6b784e9ed709d30dd3413b9ec1569071c9a1a 100644 (file)
@@ -58,6 +58,8 @@ app.
 The defaults need to be updated to log to a more generic location users are
 likely to have, or walk through setting it during the installation script.
 
+**[COMPLETED]**
+
 # Docker and Containerization
 
 I would like the Dockerfile to be rewritten such that the ENTRYPOINT is the
index 304887748cdf3e999c7a806749d2e5677469e6dc..b603ef1651807bcc1c66fbfe6a43a3596f49a49e 100644 (file)
@@ -1,8 +1,8 @@
 log4perl.rootLogger = INFO, Syslog
 log4perl.appender.Syslog = Log::Dispatch::Syslog
 log4perl.appender.Syslog.min_level = notice
-log4perl.appender.Syslog.ident = apache
-log4perl.appender.Syslog.facility = local4
+log4perl.appender.Syslog.ident = bugzilla
+log4perl.appender.Syslog.facility = daemon
 log4perl.appender.Syslog.logopt = cons,pid
 log4perl.appender.Syslog.layout = Log::Log4perl::Layout::PatternLayout
 log4perl.appender.Syslog.layout.ConversionPattern = [%c] %m{chomp}%n
index 13867aad8012b8a566e7b445d8e65640c785346c..449015b1e649fa6f874c2cb83a92c11d53d06a52 100644 (file)
@@ -222,6 +222,10 @@ END
 If you want to use the "Difference Between Two Patches" feature of the
 Patch Viewer, please specify the full path to the "interdiff" executable
 here.
+END
+  localconfig_logging_method => <<'END',
+This option specifies the method to use to log any errors or debug messages
+create by Bugzilla. This will use the configuration found in conf/log4perl-{logging_method}.conf so anything listed there is valid. Examples are 'syslog', 'docker', 'file', and 'json'.
 END
   localconfig_memcached_servers => <<'END',
 If this option is set, Bugzilla will integrate with Memcached.