Audit.FileSystem 27.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Audit.FileSystem --version 27.1.0                
NuGet\Install-Package Audit.FileSystem -Version 27.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Audit.FileSystem" Version="27.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Audit.FileSystem --version 27.1.0                
#r "nuget: Audit.FileSystem, 27.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Audit.FileSystem as a Cake Addin
#addin nuget:?package=Audit.FileSystem&version=27.1.0

// Install Audit.FileSystem as a Cake Tool
#tool nuget:?package=Audit.FileSystem&version=27.1.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

NuGet Status NuGet Count

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 globally configured 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1.1 74 10/28/2024
27.1.0 78 10/24/2024
27.0.3 103 9/25/2024
27.0.2 95 9/19/2024
27.0.1 120 9/4/2024
27.0.0 101 9/3/2024
26.0.1 120 8/22/2024
26.0.0 91 7/19/2024
25.0.7 140 7/4/2024
25.0.6 104 6/24/2024
25.0.5 89 6/18/2024
25.0.4 147 3/24/2024
25.0.3 126 3/13/2024
25.0.2 112 3/12/2024
25.0.1 118 2/28/2024
25.0.0 110 2/16/2024
24.0.1 129 2/12/2024
24.0.0 125 2/12/2024
23.0.0 222 12/14/2023
22.1.0 118 12/9/2023
22.0.2 134 12/1/2023
22.0.1 163 11/16/2023
22.0.0 125 11/14/2023
21.1.0 169 10/9/2023
21.0.4 146 9/15/2023
21.0.3 213 7/9/2023
21.0.2 182 7/6/2023
21.0.1 197 5/27/2023
21.0.0 296 4/15/2023
20.2.4 293 3/27/2023
20.2.3 288 3/17/2023
20.2.2 289 3/14/2023
20.2.1 286 3/11/2023
20.2.0 271 3/7/2023
20.1.6 320 2/23/2023
20.1.5 355 2/9/2023
20.1.4 357 1/28/2023
20.1.3 410 12/21/2022
20.1.2 342 12/14/2022
20.1.1 350 12/12/2022
20.1.0 401 12/4/2022
20.0.4 388 11/30/2022
20.0.3 723 10/28/2022
20.0.2 444 10/26/2022
20.0.1 507 10/21/2022
20.0.0 607 10/1/2022
19.4.1 590 9/10/2022
19.4.0 539 9/2/2022
19.3.0 498 8/23/2022
19.2.2 510 8/11/2022
19.2.1 561 8/6/2022
19.2.0 689 7/24/2022
19.1.4 868 5/23/2022
19.1.3 481 5/22/2022
19.1.2 589 5/18/2022
19.1.1 688 4/28/2022
19.1.0 630 4/10/2022
19.0.7 1,198 3/13/2022
19.0.6 775 3/7/2022
19.0.5 765 1/28/2022
19.0.4 559 1/23/2022
19.0.3 512 12/14/2021
19.0.2 434 12/11/2021
19.0.1 820 11/20/2021
19.0.0 440 11/11/2021
19.0.0-rc.net60.2 168 9/26/2021
19.0.0-rc.net60.1 212 9/16/2021
18.1.6 607 9/26/2021
18.1.5 441 9/7/2021
18.1.4 430 9/6/2021
18.1.3 456 8/19/2021
18.1.2 538 8/8/2021
18.1.1 499 8/5/2021
18.1.0 540 8/1/2021
18.0.1 538 7/30/2021
18.0.0 518 7/26/2021
17.0.8 537 7/7/2021
17.0.7 530 6/16/2021
17.0.6 548 6/5/2021
17.0.5 529 5/28/2021
17.0.4 531 5/4/2021
17.0.3 517 5/1/2021
17.0.2 500 4/22/2021
17.0.1 496 4/18/2021
17.0.0 520 3/26/2021
16.5.6 498 3/25/2021
16.5.5 515 3/23/2021
16.5.4 537 3/9/2021
16.5.3 485 2/26/2021
16.5.2 504 2/23/2021
16.5.1 529 2/21/2021
16.5.0 485 2/17/2021
16.4.5 446 2/15/2021
16.4.4 470 2/5/2021
16.4.3 556 1/27/2021
16.4.2 498 1/22/2021
16.4.1 561 1/21/2021
16.4.0 511 1/11/2021
16.3.3 547 1/8/2021
16.3.2 553 1/3/2021
16.3.1 570 12/31/2020
16.3.0 502 12/30/2020
16.2.1 581 12/27/2020
16.2.0 616 10/13/2020
16.1.5 532 10/4/2020
16.1.4 579 9/17/2020
16.1.3 707 9/13/2020
16.1.2 591 9/9/2020
16.1.1 623 9/3/2020
16.1.0 586 8/19/2020
16.0.3 644 8/15/2020
16.0.2 639 8/9/2020
16.0.1 655 8/8/2020
16.0.0 574 8/7/2020
15.3.0 628 7/23/2020
15.2.3 614 7/14/2020
15.2.2 1,673 5/19/2020
15.2.1 615 5/12/2020
15.2.0 641 5/9/2020
15.1.1 604 5/4/2020
15.1.0 670 4/13/2020
15.0.5 671 3/18/2020
15.0.4 658 2/28/2020
15.0.3 618 2/26/2020
15.0.2 747 1/20/2020
15.0.1 649 1/10/2020
15.0.0 677 12/17/2019
14.9.1 666 11/30/2019
14.9.0 656 11/29/2019
14.8.1 683 11/26/2019
14.8.0 672 11/20/2019
14.7.0 690 10/9/2019
14.6.6 677 10/8/2019
14.6.5 660 9/27/2019
14.6.4 705 9/21/2019
14.6.3 1,160 8/12/2019
14.6.2 718 8/3/2019
14.6.1 716 8/3/2019
14.6.0 693 7/26/2019
14.5.7 768 7/18/2019
14.5.6 746 7/10/2019
14.5.5 743 7/1/2019
14.5.4 706 6/17/2019
14.5.3 747 6/5/2019
14.5.2 732 5/30/2019
14.5.1 747 5/28/2019
14.5.0 749 5/24/2019
14.4.0 752 5/22/2019
14.3.4 742 5/14/2019
14.3.3 745 5/9/2019
14.3.2 774 4/30/2019
14.3.1 824 4/27/2019
14.3.0 799 4/24/2019
14.2.3 745 4/17/2019
14.2.2 742 4/10/2019
14.2.1 773 4/5/2019
14.2.0 746 3/16/2019
14.1.1 772 3/8/2019
14.1.0 844 2/11/2019
14.0.4 820 1/31/2019
14.0.3 874 1/22/2019
14.0.2 895 12/15/2018
14.0.1 886 11/29/2018
14.0.0 921 11/19/2018
13.3.0 940 11/16/2018
13.2.2 926 11/15/2018
13.2.1 933 11/13/2018
13.2.0 945 10/31/2018
13.1.5 897 10/31/2018
13.1.4 894 10/25/2018
13.1.3 958 10/18/2018
13.1.2 1,002 9/12/2018
13.1.1 971 9/11/2018
13.1.0 973 9/11/2018
13.0.0 1,023 8/29/2018
12.3.6 1,031 8/29/2018
12.3.5 1,049 8/22/2018
12.3.4 1,022 8/21/2018
12.3.3 25,746 8/21/2018
12.3.2 1,047 8/20/2018
12.3.1 1,015 8/20/2018
12.3.0 995 8/20/2018
12.2.2 1,079 8/15/2018
12.2.1 1,034 8/9/2018
12.2.0 1,074 8/8/2018
12.1.11 1,014 7/30/2018
12.1.10 1,068 7/20/2018
12.1.9 1,190 7/10/2018
12.1.8 1,134 7/2/2018
12.1.7 1,183 6/7/2018
12.1.6 1,046 6/4/2018
12.1.5 1,150 6/2/2018
12.1.4 1,082 5/25/2018
12.1.3 1,274 5/16/2018
12.1.2 1,140 5/15/2018
12.1.1 1,164 5/14/2018
12.1.0 1,177 5/9/2018
12.0.7 1,239 5/5/2018
12.0.6 1,232 5/4/2018
12.0.5 1,182 5/3/2018
12.0.4 1,233 4/30/2018
12.0.3 1,271 4/30/2018
12.0.2 1,223 4/27/2018
12.0.1 1,163 4/25/2018
12.0.0 1,101 4/22/2018
11.2.0 1,142 4/11/2018
11.1.0 1,184 4/8/2018
11.0.8 1,193 3/26/2018
11.0.7 1,204 3/20/2018
11.0.6 1,167 3/7/2018
11.0.5 1,132 2/22/2018
11.0.4 1,217 2/14/2018
11.0.3 1,147 2/12/2018
11.0.2 1,201 2/9/2018
11.0.1 1,099 1/29/2018
11.0.0 1,199 1/15/2018
10.0.3 1,113 12/29/2017
10.0.2 1,167 12/26/2017
10.0.1 1,251 12/18/2017
10.0.0 1,110 12/18/2017
9.3.0 1,176 12/17/2017
9.2.0 1,176 12/17/2017
9.1.3 1,101 12/5/2017
9.1.2 1,144 11/27/2017