diff --git a/CHANGELOG.md b/CHANGELOG.md index 1125ed0fc..945fbf435 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/). - Netstat collector, because network connection information wasn't used anywhere. #1535 - Checkbox to disable/enable sending log to server. #1537 - Checkbox for self deleting a monkey agent on cleanup. #1537 +- Checkbox for file logging. #1537 ### Fixed - A bug in network map page that caused delay of telemetry log loading. #1545 diff --git a/monkey/infection_monkey/config.py b/monkey/infection_monkey/config.py index 117875bb4..24a7d31bd 100644 --- a/monkey/infection_monkey/config.py +++ b/monkey/infection_monkey/config.py @@ -77,7 +77,6 @@ class Configuration(object): # logging config ########################### - use_file_logging = True dropper_log_path_windows = "%temp%\\~df1562.tmp" dropper_log_path_linux = "/tmp/user-1562" monkey_log_path_windows = "%temp%\\~df1563.tmp" diff --git a/monkey/infection_monkey/example.conf b/monkey/infection_monkey/example.conf index 1d3e3235c..5fce5aca5 100644 --- a/monkey/infection_monkey/example.conf +++ b/monkey/infection_monkey/example.conf @@ -83,7 +83,6 @@ 8088 ], "timeout_between_iterations": 10, - "use_file_logging": true, "victims_max_exploit": 100, "victims_max_find": 100, "post_breach_actions": [] diff --git a/monkey/infection_monkey/main.py b/monkey/infection_monkey/main.py index 291f35d32..a8db2ab6a 100644 --- a/monkey/infection_monkey/main.py +++ b/monkey/infection_monkey/main.py @@ -90,20 +90,17 @@ def main(): except ValueError: return True - if WormConfiguration.use_file_logging: - if os.path.exists(log_path): - # If log exists but can't be removed it means other monkey is running. This usually - # happens on upgrade - # from 32bit to 64bit monkey on Windows. In all cases this shouldn't be a problem. - try: - os.remove(log_path) - except OSError: - pass - LOG_CONFIG["handlers"]["file"]["filename"] = log_path - # noinspection PyUnresolvedReferences - LOG_CONFIG["root"]["handlers"].append("file") - else: - del LOG_CONFIG["handlers"]["file"] + if os.path.exists(log_path): + # If log exists but can't be removed it means other monkey is running. This usually + # happens on upgrade + # from 32bit to 64bit monkey on Windows. In all cases this shouldn't be a problem. + try: + os.remove(log_path) + except OSError: + pass + LOG_CONFIG["handlers"]["file"]["filename"] = log_path + # noinspection PyUnresolvedReferences + LOG_CONFIG["root"]["handlers"].append("file") logging.config.dictConfig(LOG_CONFIG) logger = logging.getLogger() diff --git a/monkey/monkey_island/cc/services/config_schema/internal.py b/monkey/monkey_island/cc/services/config_schema/internal.py index 46b2e7ca3..f503b1cbf 100644 --- a/monkey/monkey_island/cc/services/config_schema/internal.py +++ b/monkey/monkey_island/cc/services/config_schema/internal.py @@ -60,12 +60,6 @@ INTERNAL = { "monkey propagating to " "a high number of machines", }, - "use_file_logging": { - "title": "Use file logging", - "type": "boolean", - "default": True, - "description": "Should the monkey dump to a log file", - }, "serialize_config": { "title": "Serialize config", "type": "boolean", diff --git a/monkey/tests/data_for_tests/monkey_configs/monkey_config_standard.json b/monkey/tests/data_for_tests/monkey_configs/monkey_config_standard.json index e5c350531..10aac025b 100644 --- a/monkey/tests/data_for_tests/monkey_configs/monkey_config_standard.json +++ b/monkey/tests/data_for_tests/monkey_configs/monkey_config_standard.json @@ -52,7 +52,6 @@ "monkey": { "victims_max_find": 100, "victims_max_exploit": 100, - "use_file_logging": true, "serialize_config": false, "alive": true, "aws_keys": {