diff --git a/binarycpython/utils/custom_logging_functions.py b/binarycpython/utils/custom_logging_functions.py
index 218f3ae97736ba127c837b9f9e7d08e198633866..f869835b009d5421e9305a16103779e8b89c8aaa 100644
--- a/binarycpython/utils/custom_logging_functions.py
+++ b/binarycpython/utils/custom_logging_functions.py
@@ -389,13 +389,19 @@ def create_and_load_logging_function(
     else:
         tmp_dir = custom_tmp_dir
 
+    custom_logging_dir = os.path.join(tmp_dir, 'custom_logging')
+
+    # Create the subdir for the custom_logging code
+    os.makedirs(custom_logging_dir, exist_ok=True)
+
+    # 
     library_name = os.path.join(
-        temp_dir(), "libcustom_logging_{}.so".format(uuid.uuid4().hex)
+        custom_logging_dir, "libcustom_logging_{}.so".format(uuid.uuid4().hex)
     )
 
     compile_shared_lib(
         custom_logging_code,
-        sourcefile_name=os.path.join(temp_dir(), "custom_logging.c"),
+        sourcefile_name=os.path.join(custom_logging_dir, "custom_logging.c"),
         outfile_name=library_name,
         verbose=verbose,
     )