Audit.FileSystem 25.0.4

dotnet add package Audit.FileSystem --version 25.0.4
NuGet\Install-Package Audit.FileSystem -Version 25.0.4
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="25.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Audit.FileSystem --version 25.0.4
#r "nuget: Audit.FileSystem, 25.0.4"
#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=25.0.4

// Install Audit.FileSystem as a Cake Tool
#tool nuget:?package=Audit.FileSystem&version=25.0.4

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 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 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
25.0.4 94 3/24/2024
25.0.3 88 3/13/2024
25.0.2 85 3/12/2024
25.0.1 86 2/28/2024
25.0.0 82 2/16/2024
24.0.1 92 2/12/2024
24.0.0 76 2/12/2024
23.0.0 188 12/14/2023
22.1.0 88 12/9/2023
22.0.2 108 12/1/2023
22.0.1 130 11/16/2023
22.0.0 102 11/14/2023
21.1.0 138 10/9/2023
21.0.4 125 9/15/2023
21.0.3 186 7/9/2023
21.0.2 155 7/6/2023
21.0.1 171 5/27/2023
21.0.0 269 4/15/2023
20.2.4 277 3/27/2023
20.2.3 265 3/17/2023
20.2.2 264 3/14/2023
20.2.1 269 3/11/2023
20.2.0 252 3/7/2023
20.1.6 298 2/23/2023
20.1.5 329 2/9/2023
20.1.4 329 1/28/2023
20.1.3 380 12/21/2022
20.1.2 329 12/14/2022
20.1.1 331 12/12/2022
20.1.0 384 12/4/2022
20.0.4 364 11/30/2022
20.0.3 696 10/28/2022
20.0.2 425 10/26/2022
20.0.1 480 10/21/2022
20.0.0 580 10/1/2022
19.4.1 564 9/10/2022
19.4.0 519 9/2/2022
19.3.0 470 8/23/2022
19.2.2 489 8/11/2022
19.2.1 536 8/6/2022
19.2.0 671 7/24/2022
19.1.4 848 5/23/2022
19.1.3 461 5/22/2022
19.1.2 568 5/18/2022
19.1.1 660 4/28/2022
19.1.0 610 4/10/2022
19.0.7 1,094 3/13/2022
19.0.6 752 3/7/2022
19.0.5 734 1/28/2022
19.0.4 534 1/23/2022
19.0.3 494 12/14/2021
19.0.2 411 12/11/2021
19.0.1 796 11/20/2021
19.0.0 417 11/11/2021
19.0.0-rc.net60.2 161 9/26/2021
19.0.0-rc.net60.1 206 9/16/2021
18.1.6 581 9/26/2021
18.1.5 418 9/7/2021
18.1.4 413 9/6/2021
18.1.3 437 8/19/2021
18.1.2 519 8/8/2021
18.1.1 480 8/5/2021
18.1.0 525 8/1/2021
18.0.1 513 7/30/2021
18.0.0 503 7/26/2021
17.0.8 511 7/7/2021
17.0.7 505 6/16/2021
17.0.6 529 6/5/2021
17.0.5 504 5/28/2021
17.0.4 512 5/4/2021
17.0.3 492 5/1/2021
17.0.2 476 4/22/2021
17.0.1 477 4/18/2021
17.0.0 495 3/26/2021
16.5.6 479 3/25/2021
16.5.5 490 3/23/2021
16.5.4 519 3/9/2021
16.5.3 460 2/26/2021
16.5.2 486 2/23/2021
16.5.1 504 2/21/2021
16.5.0 467 2/17/2021
16.4.5 439 2/15/2021
16.4.4 451 2/5/2021
16.4.3 531 1/27/2021
16.4.2 480 1/22/2021
16.4.1 537 1/21/2021
16.4.0 493 1/11/2021
16.3.3 533 1/8/2021
16.3.2 535 1/3/2021
16.3.1 551 12/31/2020
16.3.0 484 12/30/2020
16.2.1 556 12/27/2020
16.2.0 602 10/13/2020
16.1.5 523 10/4/2020
16.1.4 553 9/17/2020
16.1.3 680 9/13/2020
16.1.2 563 9/9/2020
16.1.1 600 9/3/2020
16.1.0 567 8/19/2020
16.0.3 635 8/15/2020
16.0.2 630 8/9/2020
16.0.1 647 8/8/2020
16.0.0 560 8/7/2020
15.3.0 601 7/23/2020
15.2.3 586 7/14/2020
15.2.2 1,656 5/19/2020
15.2.1 596 5/12/2020
15.2.0 618 5/9/2020
15.1.1 589 5/4/2020
15.1.0 657 4/13/2020
15.0.5 647 3/18/2020
15.0.4 635 2/28/2020
15.0.3 597 2/26/2020
15.0.2 730 1/20/2020
15.0.1 643 1/10/2020
15.0.0 653 12/17/2019
14.9.1 653 11/30/2019
14.9.0 649 11/29/2019
14.8.1 665 11/26/2019
14.8.0 665 11/20/2019
14.7.0 666 10/9/2019
14.6.6 659 10/8/2019
14.6.5 642 9/27/2019
14.6.4 688 9/21/2019
14.6.3 1,095 8/12/2019
14.6.2 703 8/3/2019
14.6.1 703 8/3/2019
14.6.0 675 7/26/2019
14.5.7 744 7/18/2019
14.5.6 722 7/10/2019
14.5.5 720 7/1/2019
14.5.4 674 6/17/2019
14.5.3 729 6/5/2019
14.5.2 708 5/30/2019
14.5.1 715 5/28/2019
14.5.0 725 5/24/2019
14.4.0 726 5/22/2019
14.3.4 728 5/14/2019
14.3.3 722 5/9/2019
14.3.2 749 4/30/2019
14.3.1 793 4/27/2019
14.3.0 776 4/24/2019
14.2.3 721 4/17/2019
14.2.2 727 4/10/2019
14.2.1 752 4/5/2019
14.2.0 724 3/16/2019
14.1.1 748 3/8/2019
14.1.0 828 2/11/2019
14.0.4 802 1/31/2019
14.0.3 848 1/22/2019
14.0.2 875 12/15/2018
14.0.1 850 11/29/2018
14.0.0 900 11/19/2018
13.3.0 912 11/16/2018
13.2.2 904 11/15/2018
13.2.1 908 11/13/2018
13.2.0 920 10/31/2018
13.1.5 879 10/31/2018
13.1.4 882 10/25/2018
13.1.3 929 10/18/2018
13.1.2 977 9/12/2018
13.1.1 940 9/11/2018
13.1.0 940 9/11/2018
13.0.0 987 8/29/2018
12.3.6 999 8/29/2018
12.3.5 1,016 8/22/2018
12.3.4 1,000 8/21/2018
12.3.3 25,714 8/21/2018
12.3.2 1,022 8/20/2018
12.3.1 998 8/20/2018
12.3.0 972 8/20/2018
12.2.2 1,046 8/15/2018
12.2.1 1,002 8/9/2018
12.2.0 1,058 8/8/2018
12.1.11 998 7/30/2018
12.1.10 1,043 7/20/2018
12.1.9 1,155 7/10/2018
12.1.8 1,117 7/2/2018
12.1.7 1,156 6/7/2018
12.1.6 1,020 6/4/2018
12.1.5 1,123 6/2/2018
12.1.4 1,064 5/25/2018
12.1.3 1,257 5/16/2018
12.1.2 1,124 5/15/2018
12.1.1 1,153 5/14/2018
12.1.0 1,159 5/9/2018
12.0.7 1,222 5/5/2018
12.0.6 1,208 5/4/2018
12.0.5 1,156 5/3/2018
12.0.4 1,216 4/30/2018
12.0.3 1,244 4/30/2018
12.0.2 1,199 4/27/2018
12.0.1 1,146 4/25/2018
12.0.0 1,081 4/22/2018
11.2.0 1,114 4/11/2018
11.1.0 1,166 4/8/2018
11.0.8 1,173 3/26/2018
11.0.7 1,177 3/20/2018
11.0.6 1,139 3/7/2018
11.0.5 1,108 2/22/2018
11.0.4 1,190 2/14/2018
11.0.3 1,126 2/12/2018
11.0.2 1,175 2/9/2018
11.0.1 1,079 1/29/2018
11.0.0 1,174 1/15/2018
10.0.3 1,087 12/29/2017
10.0.2 1,152 12/26/2017
10.0.1 1,215 12/18/2017
10.0.0 1,093 12/18/2017
9.3.0 1,155 12/17/2017
9.2.0 1,147 12/17/2017
9.1.3 1,074 12/5/2017
9.1.2 1,134 11/27/2017