Index: branches/5.3.x/core/install/upgrades.sql
===================================================================
diff -u -r15577 -r15578
--- branches/5.3.x/core/install/upgrades.sql	(.../upgrades.sql)	(revision 15577)
+++ branches/5.3.x/core/install/upgrades.sql	(.../upgrades.sql)	(revision 15578)
@@ -2807,6 +2807,56 @@
 INSERT INTO EmailEvents (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, Module, Description, Type, AllowChangingSender, AllowChangingRecipient) VALUES(DEFAULT, 'USER.NEW.PASSWORD', NULL, 1, 0, 'Core', 'Sends new password to an existing user', 0, 1, 0);
 INSERT INTO EmailEvents (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, Module, Description, Type, AllowChangingSender, AllowChangingRecipient) VALUES(DEFAULT, 'USER.ADD.BYADMIN', NULL, 1, 0, 'Core', 'Sends password to a new user', 0, 1, 0);
 
+CREATE TABLE SystemLog (
+  LogId int(11) NOT NULL AUTO_INCREMENT,
+  LogUniqueId int(11) DEFAULT NULL,
+  LogLevel tinyint(4) NOT NULL DEFAULT '7',
+  LogType tinyint(4) NOT NULL DEFAULT '3',
+  LogCode int(11) DEFAULT NULL,
+  LogMessage longtext,
+  LogTimestamp int(11) DEFAULT NULL,
+  LogDate datetime DEFAULT NULL,
+  LogEventName varchar(100) NOT NULL DEFAULT '',
+  LogHostname varchar(255) NOT NULL DEFAULT '',
+  LogRequestSource tinyint(4) DEFAULT NULL,
+  LogRequestURI varchar(255) NOT NULL DEFAULT '',
+  LogRequestData longtext,
+  LogUserId int(11) DEFAULT NULL,
+  LogInterface tinyint(4) DEFAULT NULL,
+  IpAddress varchar(15) NOT NULL DEFAULT '',
+  LogSessionKey int(11) DEFAULT NULL,
+  LogSessionData longtext,
+  LogBacktrace longtext,
+  LogSourceFilename varchar(255) NOT NULL DEFAULT '',
+  LogSourceFileLine int(11) DEFAULT NULL,
+  LogProcessId bigint(20) unsigned DEFAULT NULL,
+  LogMemoryUsed bigint(20) unsigned NOT NULL,
+  LogUserData longtext NOT NULL,
+  LogNotificationStatus tinyint(4) NOT NULL DEFAULT '0',
+  PRIMARY KEY (LogId),
+  KEY LogLevel (LogLevel),
+  KEY LogType (LogType),
+  KEY LogNotificationStatus (LogNotificationStatus)
+);
+
+INSERT INTO SystemSettings VALUES(DEFAULT, 'EnableEmailLog', '1', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_EnableEmailLog', 'radio', NULL, '1=la_Yes||0=la_No', 65.01, 0, 1, 'hint:la_config_EnableEmailLog');
+
+UPDATE SystemSettings
+SET DisplayOrder = 65.02, Heading = 'la_section_SettingsLogs', ValueList = '86400=la_opt_OneDay||604800=la_opt_OneWeek||1209600=la_opt_TwoWeeks||2419200=la_opt_OneMonth||7257600=la_opt_ThreeMonths||29030400=la_opt_OneYear||-1=la_opt_EmailLogKeepForever'
+WHERE VariableName = 'EmailLogRotationInterval';
+
+UPDATE LanguageLabels
+SET
+	l<%PRIMARY_LANGUAGE%>_Translation = 'Keep "E-mail Log" for',
+	l<%PRIMARY_LANGUAGE%>_HintTranslation = 'This setting allows you to control for how long "E-mail Log" messages will be stored in the log and then automatically deleted. Use option "Forever" with caution since it will completely disable automatic log cleanup and can lead to large size of database table that stores e-mail messages.'
+WHERE PhraseKey = 'LA_CONFIG_EMAILLOGROTATIONINTERVAL' AND l<%PRIMARY_LANGUAGE%>_Translation = 'Keep Email Log for';
+
+DELETE FROM LanguageLabels WHERE PhraseKey = 'LA_OPT_EMAILLOGKEEPNEVER';
+
+INSERT INTO SystemSettings VALUES(DEFAULT, 'SystemLogRotationInterval', '2419200', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_SystemLogRotationInterval', 'select', NULL, '86400=la_opt_OneDay||604800=la_opt_OneWeek||1209600=la_opt_TwoWeeks||2419200=la_opt_OneMonth||7257600=la_opt_ThreeMonths||29030400=la_opt_OneYear||-1=la_opt_SystemLogKeepForever', 65.03, 0, 1, 'hint:la_config_SystemLogRotationInterval');
+INSERT INTO SystemSettings VALUES(DEFAULT, 'SystemLogNotificationEmail', '', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_SystemLogNotificationEmail', 'text', 'a:5:{s:4:"type";s:6:"string";s:9:"formatter";s:10:"kFormatter";s:6:"regexp";s:85:"/^([-a-zA-Z0-9!\\#$%&*+\\/=?^_`{|}~.]+@[a-zA-Z0-9]{1}[-.a-zA-Z0-9_]*\\.[a-zA-Z]{2,6})$/i";s:10:"error_msgs";a:1:{s:14:"invalid_format";s:18:"!la_invalid_email!";}s:7:"default";s:0:"";}', NULL, 65.04, 0, 1, 'hint:la_config_SystemLogNotificationEmail');
+INSERT INTO EmailEvents (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, Module, Description, Type, AllowChangingSender, AllowChangingRecipient) VALUES(DEFAULT, 'SYSTEM.LOG.NOTIFY', NULL, 1, 0, 'Core', 'Notification about message added to System Log', 1, 1, 1);
+
 # ===== v 5.3.0-B1 =====
 ALTER TABLE ScheduledTasks ADD Settings TEXT NULL;
 ALTER TABLE Themes ADD ImageResizeRules TEXT NULL;
