diff --git a/README.md b/README.md
index 9ecc9a3..58150b1 100644
--- a/README.md
+++ b/README.md
@@ -62,6 +62,7 @@ format={"additional_field": "value"}
  - Time to sleep between draining attempts (defaults to "3")
  - Logz.io Listener address (defaults to "https://listener.logz.io:8071")
  - Debug flag. Set to True, will print debug messages to stdout. (defaults to "False")
+ - Backup logs flag. Set to False, will disable the local backup of logs in case of failure. (defaults to "True")
 
  Please note, that you have to configure those parameters by this exact order.
  i.e. you cannot set Debug to true, without configuring all of the previous parameters as well.
diff --git a/logzio/handler.py b/logzio/handler.py
index 8767b61..0b319f3 100644
--- a/logzio/handler.py
+++ b/logzio/handler.py
@@ -16,7 +16,8 @@ class LogzioHandler(logging.Handler):
                  logzio_type="python",
                  logs_drain_timeout=3,
                  url="https://listener.logz.io:8071",
-                 debug=False):
+                 debug=False,
+                 backup_logs=True):
 
         if not token:
             raise LogzioException('Logz.io Token must be provided')
@@ -27,7 +28,8 @@ class LogzioHandler(logging.Handler):
             token=token,
             url=url,
             logs_drain_timeout=logs_drain_timeout,
-            debug=debug)
+            debug=debug,
+            backup_logs=backup_logs)
         logging.Handler.__init__(self)
 
     def extra_fields(self, message):
diff --git a/logzio/sender.py b/logzio/sender.py
index 7b51d53..6e81b26 100644
--- a/logzio/sender.py
+++ b/logzio/sender.py
@@ -32,11 +32,13 @@ class LogzioSender:
     def __init__(self,
                  token, url='https://listener.logz.io:8071',
                  logs_drain_timeout=5,
-                 debug=False):
+                 debug=False,
+                 backup_logs=True):
         self.token = token
         self.url = '{}/?token={}'.format(url, token)
         self.logs_drain_timeout = logs_drain_timeout
         self.logger = get_logger(debug)
+        self.backup_logs = backup_logs
 
         # Function to see if the main thread is alive
         self.is_main_thread_active = lambda: any(
@@ -144,7 +146,7 @@ class LogzioSender:
                     sleep(sleep_between_retries)
                     sleep_between_retries *= 2
 
-            if should_backup_to_disk:
+            if should_backup_to_disk and self.backup_logs:
                 # Write to file
                 self.logger.info(
                     'Could not send logs to Logz.io after %s tries, '

Allow to disable logs to disk
Currently there is no way to override the `should_backup_to_disk` so that it doesn't log even if the sending failed. In our application this is problematic.
diff --git a/tests/test_logzioSender.py b/tests/test_logzioSender.py
index 420688b..90242d3 100644
--- a/tests/test_logzioSender.py
+++ b/tests/test_logzioSender.py
@@ -108,6 +108,20 @@ class TestLogzioSender(TestCase):
             line = f.readline()
             self.assertTrue(log_message in line)
 
+    def test_local_file_backup_disabled(self):
+        log_message = "Backup to local filesystem"
+        self.logzio_listener.set_server_error()
+        self.logger.handlers[0].logzio_sender.backup_logs = False
+        self.logger.info(log_message)
+
+        # Make sure no file is present
+        self.assertEqual(len(_find("logzio-failures-*.txt", ".")), 0)
+
+        time.sleep(2 * 2 * 2 * 2 * 2)  # All of the retries
+
+        # Make sure no file was created
+        self.assertEqual(len(_find("logzio-failures-*.txt", ".")), 0)
+
     def test_can_send_after_fork(self):
         childpid = os.fork()
         child_log_message = 'logged from child process'

pip install -e .
parse_log_pytest
pytest
requests pytest pytest-cov future
apt-get update apt-get install -y gcc
3.6
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs @ file:///opt/conda/conda-bld/attrs_1642510447205/work
certifi==2021.5.30
charset-normalizer==2.0.12
coverage==6.2
future==1.0.0
idna==3.10
importlib-metadata @ file:///tmp/build/80754af9/importlib-metadata_1631916693255/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
-e git+https://github.com/logzio/logzio-python-handler.git@8380c4d3cfe290eea43b34157fce19376763b82c#egg=logzio_python_handler
more-itertools @ file:///tmp/build/80754af9/more-itertools_1637733554872/work
packaging @ file:///tmp/build/80754af9/packaging_1637314298585/work
pluggy @ file:///tmp/build/80754af9/pluggy_1615976315926/work
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pyparsing @ file:///tmp/build/80754af9/pyparsing_1635766073266/work
pytest==6.2.4
pytest-cov==4.0.0
requests==2.27.1
toml @ file:///tmp/build/80754af9/toml_1616166611790/work
tomli==1.2.3
typing_extensions @ file:///opt/conda/conda-bld/typing_extensions_1647553014482/work
urllib3==1.26.20
zipp @ file:///tmp/build/80754af9/zipp_1633618647012/work

name: logzio-python-handler
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=21.4.0=pyhd3eb1b0_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - importlib-metadata=4.8.1=py36h06a4308_0
  - importlib_metadata=4.8.1=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - more-itertools=8.12.0=pyhd3eb1b0_0
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=21.3=pyhd3eb1b0_0
  - pip=21.2.2=py36h06a4308_0
  - pluggy=0.13.1=py36h06a4308_0
  - py=1.11.0=pyhd3eb1b0_0
  - pyparsing=3.0.4=pyhd3eb1b0_0
  - pytest=6.2.4=py36h06a4308_2
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - toml=0.10.2=pyhd3eb1b0_0
  - typing_extensions=4.1.1=pyh06a4308_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.6.0=pyhd3eb1b0_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - charset-normalizer==2.0.12
      - coverage==6.2
      - future==1.0.0
      - idna==3.10
      - pytest-cov==4.0.0
      - requests==2.27.1
      - tomli==1.2.3
      - urllib3==1.26.20
prefix: /opt/conda/envs/logzio-python-handler

tests/test_logzioSender.py::TestLogzioSender::test_local_file_backup_disabled
tests/test_logzioSender.py::TestLogzioSender::test_can_send_after_fork tests/test_logzioSender.py::TestLogzioSender::test_local_file_backup tests/test_logzioSender.py::TestLogzioSender::test_multiple_lines_drain tests/test_logzioSender.py::TestLogzioSender::test_server_failure tests/test_logzioSender.py::TestLogzioSender::test_simple_log_drain
README.md logzio/sender.py logzio/handler.py
README.md logzio/sender.py logzio/handler.py