Audit.FileSystem
26.0.0
See the version list below for details.
dotnet add package Audit.FileSystem --version 26.0.0
NuGet\Install-Package Audit.FileSystem -Version 26.0.0
<PackageReference Include="Audit.FileSystem" Version="26.0.0" />
paket add Audit.FileSystem --version 26.0.0
#r "nuget: Audit.FileSystem, 26.0.0"
// Install Audit.FileSystem as a Cake Addin #addin nuget:?package=Audit.FileSystem&version=26.0.0 // Install Audit.FileSystem as a Cake Tool #tool nuget:?package=Audit.FileSystem&version=26.0.0
Audit.FileSystem
File System Extension for Audit.NET library.
Generate Audit Logs by intercepting file system events via FileSystemWatcher.
Audit.FileSystem provides the infrastructure to create audit logs from the file system events, like creating, renaming, modifying or deleting files and directories. It relies on FileSystemWatcher class to intercept the events, so the same limitations applies.
Install
NuGet Package
To install the package run the following command on the Package Manager Console:
PM> Install-Package Audit.FileSystem
Usage
To enable the audit log for a directory, create an instance of FileSystemMonitor
clas, and call its Start()
method:
var fsMon = new Audit.FileSystem.FileSystemMonitor(@"c:\");
fsMon.Options.IncludeSubdirectories = true;
fsMon.Start();
Or by using the FileSystemMonitorOptions
to provide the configuration:
var fsMon = new Audit.FileSystem.FileSystemMonitor(new FileSystemMonitorOptions()
{
Path = @"c:\",
IncludeSubdirectories = true,
Filter = "*.txt",
IncludeContentPredicate = fi => fi.Length <= 1024 ? FileSystem.ContentType.Text : FileSystem.ContentType.None,
CustomFilterPredicate = e => !e.FullPath.StartsWith("$RECYCLE.BIN")
});
Configuration
Output
The audit events are stored using a Data Provider. You can use one of the available data providers or implement your own. Please refer to the data providers section on Audit.NET documentation.
Settings
The FileSystemMonitorOptions
class include the following settings:
Mandatory:
- Path: The path of the directory to monitor.
Optional:
- EventTypeName: A string that identifies the event type. Default is "[{type}] {name}". Can contain the following placeholders:
- {type}: replaced with the event type (Change, Rename, Create or Delete)
- {name}: replaced with the file/directory name
- {path}: replaced with the full file/directory path
- IncludeSubdirectories: To indicate if the subdirectories of the provided
Path
should be monitored. Default is false. - IncludedEventTypes: A list indicating the event types (Change, Rename, Create or Delete) that should be included on the audit. Default is NULL meaning all the event types will be logged.
- Filter: The filter string used to determine what files are monitored. Default is "*.*"
- CustomFilterPredicate: Allows to filter events with a custom function that given a file event, returns true if the entry should be logged and false otherwise. Default includes all the files satisfying the provided
Filter
string. - IncludeContentPredicate: Allows to determine if the file contents should be included in the log with a custom function that given a file event, returns a
ContentType
indicating whether the contents should be included as a string (Text
), as a byte array (Binary
) or not included (None
). By default content is not included. - NotifyFilters: The notify filters. Default is DirectoryName | FileName | LastAccess | LastWrite.
- IgnoreMD5: To indicate if the MD5 computation should be ignored. By default the MD5 hash of the file is included on the log.
- InternalBufferSize: Gets or sets the size (in bytes) of the internal buffer.
- AuditDataProvider: To indicate the Audit Data Provider to use. Default is NULL to use the globally configured data provider.
- CreationPolicy: To indicate the event creation policy to use. Default is NULL to use the globally configured creation policy.
- AuditScopeFactory: Allows to set a specific audit scope factory. By default the general
AuditScopeFactory
is used.
Output
Audit.FileSystem output includes:
- Execution time.
- Environment information.
- File/Directory name, attributes and properties
- File MD5 hash (optional)
- File contents (optional)
Output Details
The following table describes the Audit.FileSystem output fields:
FileSystemEvent
Describes an event from the file system.
Field Name | Type | Description |
---|---|---|
Object | FileSystemObjectType | Indicates the object type: File , Directory or Unknown |
Event | FileSystemEventType | The file system event type: Create , change , Rename or Delete |
Errors | string | Any error encountered when processing the file/directory |
Attributes | string | The file/directory attributes |
Name | string | The file/directory name |
OldName | string | In case of rename, the old file/directory name |
Extension | string | The file extension including the point |
FullPath | string | The full path to the file/directory |
Length | long | The file length in bytes |
CreationTime | datetime | The file/directory creation date and time |
LastAccessTime | datetime | The file/directory last access date and time |
LastWriteTime | datetime | The file/directory last write date and time |
ReadOnly | boolean | Value indicating if the file is read only |
MD5 | boolean | The MD5 hash of the file |
FileContent | FileContent | The file contents when included |
FileContent
Represents the contents of an audited file.
Field Name | Type | Description |
---|---|---|
Type | ContentType | The content type: Text or Binary |
Value | string/byte array | The string (text) or byte array (binary) with the file contents |
Output Sample
File creation:
{
"EventType": "[Created] file.txt",
"Environment": {
"UserName": "Federico",
"MachineName": "HP",
"DomainName": "HP",
"Culture": "en-US"
},
"StartDate": "2017-11-26T23:01:44.5567169-06:00",
"EndDate": "2017-11-26T23:01:44.5567169-06:00",
"Duration": 0,
"FileSystemEvent": {
"Object": "File",
"Event": "Create",
"Attributes": "Archive",
"Name": "file.txt",
"Extension": ".txt",
"FullPath": "c:\\Users\\Federico\\Documents\\file.txt",
"Length": 694,
"CreationTime": "2017-11-26T23:01:11.750589-06:00",
"LastAccessTime": "2017-11-26T23:01:11.750589-06:00",
"LastWriteTime": "2017-11-26T23:01:11.7515849-06:00",
"MD5": "ddc032e5fe9bb3aa15144cdc35d959c5"
}
}
File renaming
{
"EventType": "[Renamed] renamed.txt",
"Environment": {
"UserName": "Federico",
"MachineName": "HP",
"DomainName": "HP",
"Culture": "en-US"
},
"StartDate": "2017-11-26T23:01:37.8409103-06:00",
"EndDate": "2017-11-26T23:01:37.8409103-06:00",
"Duration": 0,
"FileSystemEvent": {
"Object": "File",
"Event": "Rename",
"OldName": "file.txt",
"Name": "renamed.txt",
"Extension": ".txt",
"FullPath": "c:\\Users\\Federico\\Documents\\renamed.txt"
}
}
IO Exception:
{
"EventType": "[Created] tmpFC2D.tmp",
"Environment": {
"UserName": "Federico",
"MachineName": "HP",
"DomainName": "HP",
"Culture": "en-US"
},
"StartDate": "2017-11-26T23:01:03.7363727-06:00",
"EndDate": "2017-11-26T23:01:03.7363727-06:00",
"Duration": 0,
"FileSystemEvent": {
"Object": "File",
"Event": "Create",
"Errors": [
"IOException when getting file attributes: Could not find file 'c:\\Users\\Federico\\AppData\\Local\\Temp\\tmpFC2D.tmp'."
],
"Name": "tmpFC2D.tmp",
"Extension": ".tmp",
"FullPath": "c:\\Users\\Federico\\AppData\\Local\\Temp\\tmpFC2D.tmp"
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Audit.NET (>= 26.0.0)
- System.Text.Json (>= 6.0.9)
-
.NETStandard 2.0
- Audit.NET (>= 26.0.0)
- System.Text.Json (>= 6.0.9)
-
net6.0
- Audit.NET (>= 26.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Audit.FileSystem:
Package | Downloads |
---|---|
RezisFramework
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
27.2.0 | 77 | 11/23/2024 |
27.1.1 | 81 | 10/28/2024 |
27.1.0 | 83 | 10/24/2024 |
27.0.3 | 106 | 9/25/2024 |
27.0.2 | 98 | 9/19/2024 |
27.0.1 | 123 | 9/4/2024 |
27.0.0 | 104 | 9/3/2024 |
26.0.1 | 123 | 8/22/2024 |
26.0.0 | 94 | 7/19/2024 |
25.0.7 | 184 | 7/4/2024 |
25.0.6 | 107 | 6/24/2024 |
25.0.5 | 92 | 6/18/2024 |
25.0.4 | 150 | 3/24/2024 |
25.0.3 | 129 | 3/13/2024 |
25.0.2 | 115 | 3/12/2024 |
25.0.1 | 121 | 2/28/2024 |
25.0.0 | 113 | 2/16/2024 |
24.0.1 | 132 | 2/12/2024 |
24.0.0 | 130 | 2/12/2024 |
23.0.0 | 226 | 12/14/2023 |
22.1.0 | 121 | 12/9/2023 |
22.0.2 | 139 | 12/1/2023 |
22.0.1 | 166 | 11/16/2023 |
22.0.0 | 128 | 11/14/2023 |
21.1.0 | 172 | 10/9/2023 |
21.0.4 | 149 | 9/15/2023 |
21.0.3 | 216 | 7/9/2023 |
21.0.2 | 185 | 7/6/2023 |
21.0.1 | 200 | 5/27/2023 |
21.0.0 | 301 | 4/15/2023 |
20.2.4 | 296 | 3/27/2023 |
20.2.3 | 293 | 3/17/2023 |
20.2.2 | 292 | 3/14/2023 |
20.2.1 | 289 | 3/11/2023 |
20.2.0 | 274 | 3/7/2023 |
20.1.6 | 323 | 2/23/2023 |
20.1.5 | 358 | 2/9/2023 |
20.1.4 | 360 | 1/28/2023 |
20.1.3 | 416 | 12/21/2022 |
20.1.2 | 345 | 12/14/2022 |
20.1.1 | 353 | 12/12/2022 |
20.1.0 | 404 | 12/4/2022 |
20.0.4 | 391 | 11/30/2022 |
20.0.3 | 726 | 10/28/2022 |
20.0.2 | 447 | 10/26/2022 |
20.0.1 | 510 | 10/21/2022 |
20.0.0 | 610 | 10/1/2022 |
19.4.1 | 593 | 9/10/2022 |
19.4.0 | 542 | 9/2/2022 |
19.3.0 | 501 | 8/23/2022 |
19.2.2 | 513 | 8/11/2022 |
19.2.1 | 568 | 8/6/2022 |
19.2.0 | 692 | 7/24/2022 |
19.1.4 | 871 | 5/23/2022 |
19.1.3 | 484 | 5/22/2022 |
19.1.2 | 592 | 5/18/2022 |
19.1.1 | 691 | 4/28/2022 |
19.1.0 | 633 | 4/10/2022 |
19.0.7 | 1,201 | 3/13/2022 |
19.0.6 | 778 | 3/7/2022 |
19.0.5 | 768 | 1/28/2022 |
19.0.4 | 562 | 1/23/2022 |
19.0.3 | 515 | 12/14/2021 |
19.0.2 | 437 | 12/11/2021 |
19.0.1 | 823 | 11/20/2021 |
19.0.0 | 443 | 11/11/2021 |
19.0.0-rc.net60.2 | 169 | 9/26/2021 |
19.0.0-rc.net60.1 | 213 | 9/16/2021 |
18.1.6 | 610 | 9/26/2021 |
18.1.5 | 444 | 9/7/2021 |
18.1.4 | 433 | 9/6/2021 |
18.1.3 | 459 | 8/19/2021 |
18.1.2 | 541 | 8/8/2021 |
18.1.1 | 502 | 8/5/2021 |
18.1.0 | 543 | 8/1/2021 |
18.0.1 | 541 | 7/30/2021 |
18.0.0 | 521 | 7/26/2021 |
17.0.8 | 540 | 7/7/2021 |
17.0.7 | 533 | 6/16/2021 |
17.0.6 | 551 | 6/5/2021 |
17.0.5 | 532 | 5/28/2021 |
17.0.4 | 534 | 5/4/2021 |
17.0.3 | 520 | 5/1/2021 |
17.0.2 | 503 | 4/22/2021 |
17.0.1 | 499 | 4/18/2021 |
17.0.0 | 523 | 3/26/2021 |
16.5.6 | 501 | 3/25/2021 |
16.5.5 | 518 | 3/23/2021 |
16.5.4 | 540 | 3/9/2021 |
16.5.3 | 488 | 2/26/2021 |
16.5.2 | 507 | 2/23/2021 |
16.5.1 | 532 | 2/21/2021 |
16.5.0 | 488 | 2/17/2021 |
16.4.5 | 449 | 2/15/2021 |
16.4.4 | 473 | 2/5/2021 |
16.4.3 | 559 | 1/27/2021 |
16.4.2 | 501 | 1/22/2021 |
16.4.1 | 564 | 1/21/2021 |
16.4.0 | 514 | 1/11/2021 |
16.3.3 | 550 | 1/8/2021 |
16.3.2 | 556 | 1/3/2021 |
16.3.1 | 573 | 12/31/2020 |
16.3.0 | 505 | 12/30/2020 |
16.2.1 | 584 | 12/27/2020 |
16.2.0 | 619 | 10/13/2020 |
16.1.5 | 535 | 10/4/2020 |
16.1.4 | 582 | 9/17/2020 |
16.1.3 | 710 | 9/13/2020 |
16.1.2 | 594 | 9/9/2020 |
16.1.1 | 626 | 9/3/2020 |
16.1.0 | 589 | 8/19/2020 |
16.0.3 | 647 | 8/15/2020 |
16.0.2 | 642 | 8/9/2020 |
16.0.1 | 658 | 8/8/2020 |
16.0.0 | 577 | 8/7/2020 |
15.3.0 | 631 | 7/23/2020 |
15.2.3 | 617 | 7/14/2020 |
15.2.2 | 1,676 | 5/19/2020 |
15.2.1 | 618 | 5/12/2020 |
15.2.0 | 644 | 5/9/2020 |
15.1.1 | 607 | 5/4/2020 |
15.1.0 | 673 | 4/13/2020 |
15.0.5 | 674 | 3/18/2020 |
15.0.4 | 661 | 2/28/2020 |
15.0.3 | 621 | 2/26/2020 |
15.0.2 | 750 | 1/20/2020 |
15.0.1 | 652 | 1/10/2020 |
15.0.0 | 680 | 12/17/2019 |
14.9.1 | 669 | 11/30/2019 |
14.9.0 | 659 | 11/29/2019 |
14.8.1 | 686 | 11/26/2019 |
14.8.0 | 675 | 11/20/2019 |
14.7.0 | 693 | 10/9/2019 |
14.6.6 | 680 | 10/8/2019 |
14.6.5 | 663 | 9/27/2019 |
14.6.4 | 708 | 9/21/2019 |
14.6.3 | 1,163 | 8/12/2019 |
14.6.2 | 721 | 8/3/2019 |
14.6.1 | 719 | 8/3/2019 |
14.6.0 | 696 | 7/26/2019 |
14.5.7 | 771 | 7/18/2019 |
14.5.6 | 749 | 7/10/2019 |
14.5.5 | 746 | 7/1/2019 |
14.5.4 | 709 | 6/17/2019 |
14.5.3 | 750 | 6/5/2019 |
14.5.2 | 735 | 5/30/2019 |
14.5.1 | 750 | 5/28/2019 |
14.5.0 | 752 | 5/24/2019 |
14.4.0 | 755 | 5/22/2019 |
14.3.4 | 745 | 5/14/2019 |
14.3.3 | 748 | 5/9/2019 |
14.3.2 | 777 | 4/30/2019 |
14.3.1 | 827 | 4/27/2019 |
14.3.0 | 802 | 4/24/2019 |
14.2.3 | 748 | 4/17/2019 |
14.2.2 | 745 | 4/10/2019 |
14.2.1 | 776 | 4/5/2019 |
14.2.0 | 749 | 3/16/2019 |
14.1.1 | 775 | 3/8/2019 |
14.1.0 | 847 | 2/11/2019 |
14.0.4 | 823 | 1/31/2019 |
14.0.3 | 877 | 1/22/2019 |
14.0.2 | 898 | 12/15/2018 |
14.0.1 | 889 | 11/29/2018 |
14.0.0 | 924 | 11/19/2018 |
13.3.0 | 943 | 11/16/2018 |
13.2.2 | 929 | 11/15/2018 |
13.2.1 | 936 | 11/13/2018 |
13.2.0 | 948 | 10/31/2018 |
13.1.5 | 900 | 10/31/2018 |
13.1.4 | 897 | 10/25/2018 |
13.1.3 | 961 | 10/18/2018 |
13.1.2 | 1,005 | 9/12/2018 |
13.1.1 | 974 | 9/11/2018 |
13.1.0 | 976 | 9/11/2018 |
13.0.0 | 1,026 | 8/29/2018 |
12.3.6 | 1,034 | 8/29/2018 |
12.3.5 | 1,052 | 8/22/2018 |
12.3.4 | 1,025 | 8/21/2018 |
12.3.3 | 25,749 | 8/21/2018 |
12.3.2 | 1,050 | 8/20/2018 |
12.3.1 | 1,018 | 8/20/2018 |
12.3.0 | 998 | 8/20/2018 |
12.2.2 | 1,084 | 8/15/2018 |
12.2.1 | 1,037 | 8/9/2018 |
12.2.0 | 1,077 | 8/8/2018 |
12.1.11 | 1,017 | 7/30/2018 |
12.1.10 | 1,071 | 7/20/2018 |
12.1.9 | 1,193 | 7/10/2018 |
12.1.8 | 1,137 | 7/2/2018 |
12.1.7 | 1,186 | 6/7/2018 |
12.1.6 | 1,049 | 6/4/2018 |
12.1.5 | 1,153 | 6/2/2018 |
12.1.4 | 1,085 | 5/25/2018 |
12.1.3 | 1,277 | 5/16/2018 |
12.1.2 | 1,143 | 5/15/2018 |
12.1.1 | 1,167 | 5/14/2018 |
12.1.0 | 1,180 | 5/9/2018 |
12.0.7 | 1,242 | 5/5/2018 |
12.0.6 | 1,235 | 5/4/2018 |
12.0.5 | 1,185 | 5/3/2018 |
12.0.4 | 1,236 | 4/30/2018 |
12.0.3 | 1,274 | 4/30/2018 |
12.0.2 | 1,226 | 4/27/2018 |
12.0.1 | 1,168 | 4/25/2018 |
12.0.0 | 1,104 | 4/22/2018 |
11.2.0 | 1,145 | 4/11/2018 |
11.1.0 | 1,187 | 4/8/2018 |
11.0.8 | 1,196 | 3/26/2018 |
11.0.7 | 1,207 | 3/20/2018 |
11.0.6 | 1,170 | 3/7/2018 |
11.0.5 | 1,135 | 2/22/2018 |
11.0.4 | 1,222 | 2/14/2018 |
11.0.3 | 1,150 | 2/12/2018 |
11.0.2 | 1,204 | 2/9/2018 |
11.0.1 | 1,102 | 1/29/2018 |
11.0.0 | 1,202 | 1/15/2018 |
10.0.3 | 1,116 | 12/29/2017 |
10.0.2 | 1,172 | 12/26/2017 |
10.0.1 | 1,254 | 12/18/2017 |
10.0.0 | 1,113 | 12/18/2017 |
9.3.0 | 1,179 | 12/17/2017 |
9.2.0 | 1,179 | 12/17/2017 |
9.1.3 | 1,104 | 12/5/2017 |
9.1.2 | 1,147 | 11/27/2017 |