Skip to content

Commit

Permalink
Item8668: Item12022: Improve Compatibility logger
Browse files Browse the repository at this point in the history
The PlainFile logger has serious performance issues when rotating very
large log files on busy systems.  This checkin makes it easier to choose
the Compatibility logger:

 - Restore the  LogFileName, DebugFileName and WarningFileName settings
   to Foswiki.spec.  Default is empty, so they are not used on new
   installations.
 - Add checkers for these settings.  Note that they are deprecated, and
   should be removed unless the Compatibility logger is desired.
 - Add a note that PlainFile logger has a performance issue at end of
   month, when rotating very large files on busy systems.
 - Note that old TWiki extensions might wite directly to the
   LogFileName.

This also partially solves the issue of upgraders being asked to
manually edit LocalSite.cfg to remove the obsolete settings.


Conflicts:

	core/lib/Foswiki.spec

git-svn-id: http://svn.foswiki.org/branches/Release01x01@15622 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Oct 17, 2012
1 parent f98c5e0 commit ee63881
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 13 deletions.
10 changes: 6 additions & 4 deletions core/lib/Foswiki.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,7 @@ sub new {
# Compatibility; not used except maybe in plugins
$Foswiki::cfg{TempfileDir} = "$Foswiki::cfg{WorkingDir}/tmp"
unless defined( $Foswiki::cfg{TempfileDir} );

if ( defined $Foswiki::cfg{WarningFileName}
&& $Foswiki::cfg{Log}{Implementation} eq 'Foswiki::Logger::PlainFile' )
{
Expand All @@ -1654,11 +1655,12 @@ sub new {
}
else {

# Otherwise make sure it is defined for use in plugins,
# Otherwise make sure it is defined for use in old plugins,
# but don't overwrite the setting from configure, if there is one.
# This is especially important when the admin has *chosen*
# to use the compatibility logger.
if ( not defined $Foswiki::cfg{LogFileName} ) {
# to use the compatibility logger. (Some old TWiki heritage
# plugins write directly to the configured LogFileName
if ( not $Foswiki::cfg{LogFileName} ) {
$Foswiki::cfg{LogFileName} = "$Foswiki::cfg{Log}{Dir}/events.log";
}
}
Expand Down Expand Up @@ -3769,7 +3771,7 @@ sub getApproxRevTime {
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors
Copyright (C) 2008-2012 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
Expand Down
31 changes: 27 additions & 4 deletions core/lib/Foswiki.spec
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,8 @@ $Foswiki::cfg{Log}{Dir} = '$Foswiki::cfg{WorkingDir}/logs';
# for a large site, or even provide your own custom logger. Select the
# implementation to be used here. Most sites should be OK with the
# PlainFile logger, which automatically rotates the logs every month.<p />
# Note that on very busy systems, this logfile rotation can be disruptive and the
# Compatibility logger might perform better.<p />
# The <tt>PlainFile::Obfuscating</tt> logger is identical to the <tt>PlainFile</tt>
# logger except that IP addresses are either obfuscated by replacing the IP Address
# with a MD5 Hash, or by completely masking it to x.x.x.x. If your regulatory domain
Expand All @@ -849,10 +851,6 @@ $Foswiki::cfg{Log}{Dir} = '$Foswiki::cfg{WorkingDir}/logs';
# through use of the <tt>Foswiki::Logger::Compatibility</tt> logger.
# Foswiki will automatically select the Compatibility logger if it detects
# a setting for <tt>{WarningFileName}</tt> in your LocalSite.cfg.
# You are recommended to change to the PlainFile logger at your earliest
# convenience by removing <tt>{WarningFileName}</tt>,
# <tt>{LogFileName}</tt> and <tt>{DebugFileName}</tt>
# from LocalSite.cfg and re-running configure.
$Foswiki::cfg{Log}{Implementation} = 'Foswiki::Logger::PlainFile';
# **BOOLEAN EXPERT**
Expand Down Expand Up @@ -884,6 +882,31 @@ $Foswiki::cfg{Log}{Action} = {
viewfile => 1,
};
# **PATH DISPLAY_IF /Compatibility/i.test({Log}{Implementation}) || {DebugFileName}**
# Log file for debug messages when using the Compatibility logger.
# (Usually very low volume.) If <code>%DATE%</code> is included in the file name, it gets expanded
# to YYYYMM (year, month), causing a new log to be written each month.<p />
# To use the Compatibility logger, set this to a valid file path and name.<br />
# Foswiki 1.0.x default: <code>$Foswiki::cfg{DataDir}/debug.txt</code>
$Foswiki::cfg{DebugFileName} = '';
# **PATH DISPLAY_IF /Compatibility/i.test({Log}{Implementation}) || {WarningFileName}**
# Log file for Warnings when using the Compatibility logger.
# (Usually low volume) If <code>%DATE%</code> is included in the file name, it gets expanded
# to YYYYMM (year, month), causing a new log to be written each month.<p />
# To use the Compatibility logger, set this to a valid file path and name.<br />
# Foswiki 1.0.x default: <code>$Foswiki::cfg{DataDir}/warn%DATE%.txt</code>
$Foswiki::cfg{WarningFileName} = '';
# **PATH**
# Log file recording web activity when using the Compatibility logger. (High volume).
# If <code>%DATE%</code> is included in the file name, it gets expanded
# to YYYYMM (year, month), causing a new log to be written each month.<p />
# To use the Compatibility logger, set this to a valid file path and name.<p />
# Foswiki 1.0.x default: <code>$Foswiki::cfg{DataDir}/log%DATE%.txt</code>
$Foswiki::cfg{LogFileName} = '';
# **NUMBER**
# Number of top viewed topics to show in statistics topic
$Foswiki::cfg{Stats}{TopViews} = 10;
Expand Down
56 changes: 56 additions & 0 deletions core/lib/Foswiki/Configure/Checkers/DebugFileName.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::DebugFileName;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');

use Foswiki::Configure::Load ();

sub check {
my $this = shift;
my $mess = '';

if ( $Foswiki::cfg{DebugFileName} ) {
$mess .= $this->WARN(
'This setting is deprecated. Delete it unless you want to use the CompatibilityLogger'
);
$mess .= $this->showExpandedValue( $Foswiki::cfg{DebugFileName} );
}
else {
if ( $Foswiki::cfg{Log}{Implementation} eq
'Foswiki::Logger::Compatibility' )
{
$mess .= $this->WARN(
'This setting is recommended for the CompatibilityLogger. If not set, logs are written to <code>$Foswiki::cfg{DataDir}/debug%DATE%.txt</code>'
);
$mess .= $this->NOTE(
'Foswiki 1.0.x configuration default was <code>$Foswiki::cfg{DataDir}/debug.txt</code>'
);
}
}

return $mess;
}

1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2012 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. For
more details read LICENSE in the root of this distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
As per the GPL, removal of this notice is prohibited.
22 changes: 17 additions & 5 deletions core/lib/Foswiki/Configure/Checkers/Log/Implementation.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,25 @@ sub check {

if ( $Foswiki::cfg{Log}{Implementation} eq 'Foswiki::Logger::PlainFile' ) {

# Look for legacy logger settings
$mess .= $this->NOTE( <<WARN );
On busy systems with large log files, the PlainFile logger can encounter issues when rotating the logs at the end of the month.
The older Compatibility logger, or the new LogDispatchContrib are preferable on busy systems.
WARN

# Look for legacy logger settings, except for LogFileName. Some old TWiki plugins write directly to
# this file. So it should still be configurable even if using a different logger.
my @legacyLoggerFilenames;
foreach my $setting (qw/LogFileName WarningFileName DebugFileName/) {
foreach my $setting (qw/WarningFileName DebugFileName/) {
push @legacyLoggerFilenames, $setting
if defined $Foswiki::cfg{$setting};
if $Foswiki::cfg{$setting};
}

# Select the compatibility logger and warn about it,
# if any legacy logger settings were found
if (@legacyLoggerFilenames) {
if ( @legacyLoggerFilenames
&& $Foswiki::cfg{Log}{Implementation} eq
'Foswiki::Logger::PlainFile' )
{
$Foswiki::cfg{Log}{Implementation} =
'Foswiki::Logger::Compatibility';

Expand All @@ -40,6 +49,9 @@ sub check {
"Found a setting for $legacyLoggerFilenames[0] in LocalSite.cfg, so I have automatically selected the Compatibility logger. "
);
}
$mess .= $this->NOTE(
'Remove the settings for WarningFileName and DebugFileName to use the PlainFile Logger.'
);
}
}
return $mess;
Expand All @@ -49,7 +61,7 @@ sub check {
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors
Copyright (C) 2008-2012 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
Expand Down
61 changes: 61 additions & 0 deletions core/lib/Foswiki/Configure/Checkers/LogFileName.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::LogFileName;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');

use Foswiki::Configure::Load ();

sub check {
my $this = shift;
my $mess = '';
unless (
$Foswiki::cfg{Log}{Implementation} eq 'Foswiki::Logger::Compatibility' )
{

$mess .= $this->NOTE( <<NOTE );
This setting might be used by old plugins that have not been migrated to the Foswiki API.
If not provided, Foswik core will provide a default setting of <code>$Foswiki::cfg{Log}{Dir}/event.log</code>.
NOTE
my $logger = $Foswiki::cfg{Log}{Implementation};
$logger =~ s/Foswiki::Logger:://;
$mess .= $this->NOTE("It is not used by the $logger logger.");
}
if ( $Foswiki::cfg{LogFileName} ) {
$mess .= $this->showExpandedValue( $Foswiki::cfg{LogFileName} );
}
else {
if ( $Foswiki::cfg{Log}{Implementation} eq
'Foswiki::Logger::Compatibility' )
{
$mess .= $this->WARN(
'This setting is recommended for the CompatibilityLogger. If not set, logs are written to <code>$Foswiki::cfg{DataDir}/log%DATE%.txt</code>'
);
}
}

return $mess;
}

1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2012 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. For
more details read LICENSE in the root of this distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
As per the GPL, removal of this notice is prohibited.
53 changes: 53 additions & 0 deletions core/lib/Foswiki/Configure/Checkers/WarningFileName.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::WarningFileName;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');

use Foswiki::Configure::Load ();

sub check {
my $this = shift;
my $mess = '';

if ( $Foswiki::cfg{WarningFileName} ) {
$mess .= $this->NOTE(
'This setting is deprecated. Delete it unless you want to use the CompatibilityLogger'
);
$mess .= $this->showExpandedValue( $Foswiki::cfg{WarningFileName} );
}
else {
if ( $Foswiki::cfg{Log}{Implementation} eq
'Foswiki::Logger::Compatibility' )
{
$mess .= $this->WARN(
'This setting is recommended for the CompatibilityLogger. If not set, logs are written to <code>$Foswiki::cfg{DataDir}/warn%DATE%.txt</code>'
);
}
}

return $mess;
}

1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2012 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. For
more details read LICENSE in the root of this distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
As per the GPL, removal of this notice is prohibited.

0 comments on commit ee63881

Please sign in to comment.