FileAccessLogger is a tool designed to monitor a specific file for modifications or creations and log the processes that access this file. It uses the watchdog
library to observe the file system and the psutil
library to track processes interacting with the file. All process activities related to the file are logged into a text file.
- Monitors a specified file for any modifications or creations.
- Logs the processes (including PID and process name) that access the monitored file.
- Continuously runs until interrupted, allowing real-time monitoring.
- Outputs logs to
process_log.txt
file.
- Python 3
watchdog
library (for file system event handling)psutil
library (for process information retrieval)
-
Install the required libraries:
- Install the necessary Python libraries by running:
pip install watchdog psutil
- Install the necessary Python libraries by running:
-
Running the Script:
-
Start the file monitoring by running:
python main.py
-
The
main.py
script will monitor the filemali_tablolar.xlsx
by default. You can modify the script to monitor any other file.
-
-
Customizing the Monitored File:
- To monitor a different file, change the
file_to_watch
variable in themain.py
script:file_to_watch = "your_file_name_here"
- Replace
"your_file_name_here"
with the path to the file you want to monitor.
- To monitor a different file, change the
-
Monitor a File:
- By default, the script monitors
mali_tablolar.xlsx
. - Any process that accesses or modifies this file will be logged in
process_log.txt
.
- By default, the script monitors
-
Log Format:
- Each log entry includes the timestamp, the file accessed, and the details of the processes that accessed the file:
[Thu Mar 4 10:20:42 2024] mali_tablolar.xlsx accessed by: PID: 12345, Name: python.exe
- Each log entry includes the timestamp, the file accessed, and the details of the processes that accessed the file:
- Allow the user to specify the file to monitor via command-line arguments.
- Enhance logging to include more detailed process information.
- Implement a feature to alert the user when a specific process accesses the file.
If you have any questions or suggestions, feel free to contact the project maintainer at [email protected].