11 private StreamWriter file;
12 private readonly
string fileName;
13 private readonly
int deleteAfterDays;
57 this.fileName = FileName;
58 this.deleteAfterDays = DeleteAfterDays;
60 string FolderName = Path.GetDirectoryName(FileName);
62 if (!Directory.Exists(FolderName))
65 Directory.CreateDirectory(FolderName);
74 if (!(this.file is
null))
92 this.output = this.file = File.AppendText(s);
95 this.output = this.file = File.CreateText(s);
97 if (this.deleteAfterDays <
int.MaxValue)
99 string FolderName = Path.GetDirectoryName(s);
100 if (
string.IsNullOrEmpty(FolderName))
103 string[] Files = Directory.GetFiles(FolderName,
"*.*");
105 foreach (
string FileName
in Files)
107 if ((DateTime.Now - File.GetLastWriteTime(FileName)).TotalDays >=
this.deleteAfterDays)
111 File.Delete(FileName);
137 base.DisposeOutput();
139 this.file?.Dispose();
Outputs sniffed data to a text file.
TextFileEventSink(string ObjectID, string FileName)
Outputs sniffed data to a text file.
TextFileEventSink(string ObjectID, string FileName, int DeleteAfterDays)
Outputs sniffed data to a text file.
override void AfterWrite()
Method is called after writing something to the text file.
override void DisposeOutput()
Disposes of the current output.
override void BeforeWrite()
Method is called before writing something to the text file.
Outputs sniffed data to a text writer.
Outputs sniffed data to an XML file.
static string GetFileName(string TemplateFileName)
Gets the name of a file, given a file name template.
Static class managing the application event log. Applications and services log events on this static ...
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
virtual string ObjectID
Object ID, used when logging events.