Click or drag to resize

Logger class

Writes messages with added timestamps to log files; implements IInfoViewer.
Inheritance hierarchy
SystemObject
  NetEti.ApplicationControlLoggerBase
    NetEti.ApplicationControlLogger

Namespace: NetEti.ApplicationControl
Assembly: NetEti.Logging (in NetEti.Logging.dll) Version: 1.0.0+b865061c8026804ece26684b7dc3403284234a08
Syntax
public class Logger : LoggerBase, IShowable

The Logger Type exposes the following members.

Constructors
 NameDescription of the
Public MethodLogger Parameterless constructor: sets the log file to GetEnvironmentVariable("TEMP") + \ + ProductName + @".log" and calls the next constructor.
Public MethodLogger(Boolean) Constructor: takes over plainMessage, sets the log file to GetEnvironmentVariable("TEMP") + \ + ProductName + @".log" and calls the next constructor.
Public MethodLogger(String) Constructor: takes over logFilePathName, sets plainMessage to false and calls the next constructor.
Public MethodLogger(Boolean, String) Constructor: takes over plainMessage and regexFilter, sets the log file to GetEnvironmentVariable("TEMP") + \ + ProductName + @".log" and calls the next constructor.
Public MethodLogger(String, Boolean) Constructor: takes over logFilePathName and plainMessage, sets regexFilter to "" and calls the next constructor.
Public MethodLogger(String, String, Boolean) Complete constructor.
Back to the top
Properties
 NameDescription of the
Public PropertyDebugArchiveMaxCount Maximum number of archived logs (debug files, etc.). If there is a surplus, the oldest ones are deleted. Default: 0 (corresponds to an infinite number).
(Inherited from LoggerBase)
Public PropertyDebugArchivingInterval Time interval in which the current logging (DebugFile, etc.) is archived and emptied. Must be set externally. Default: TimeSpan.Zero.
(Inherited from LoggerBase)
Public PropertyIsTimerTriggered With True, the logging output is time-controlled. LoggingTriggerCounter then returns the number of milliseconds until the next trigger event. If False, the output is divided by the total number counting processes are controlled. LoggingTriggerCounter defined here is the number of counting processes after which the output takes place; Default: True.
(Inherited from LoggerBase)
Public PropertyLoggingTriggerCounter Number of milliseconds or number of counting operations until the next logging output; Default: 5000.
(Inherited from LoggerBase)
Public PropertyLogTargetInfo Target path, e.g. for text logs, name and path of the log file.
(Inherited from LoggerBase)
Public PropertyMaxBufferLineCount Maximum number of lines that a MessageBuffer can hold, before it is forcibly flushed. This setting works even with timer-controlled logging. Default: 10000.
(Inherited from LoggerBase)
Protected PropertyPlainMessage If True, messages are output unchanged; due to asynchrony of message handling can lead to sequence swaps. If False, messages are provided with a timestamp and are prefixed with Flush of the message buffer sorted by timestamp. Default: False.
(Inherited from LoggerBase)
Public PropertyStandardIndent Indentation of subsequent lines for multi-line messages. Default: 4.
Back to the top
Methods
 NameDescription of the
Public MethodDispose Public method for cleaning up.
(Inherited from LoggerBase)
Protected MethodDispose(Boolean) This can be tidied up if necessary.
(Inherited from LoggerBase)
Protected MethodFinalise Finaliser: is called by the GarbageCollector.
(Inherited from LoggerBase)
Public MethodFlush Ensures that all pending actions are executed. e.g. filled intermediate tables (buffers) are processed (flushed).
(Inherited from LoggerBase)
Public MethodHandleInfo Callback for logging the message: is created by the responsible InfoController provided that you have registered in advance.
(Overwrites LoggerBaseHandleInfo(Object, InfoArgs))
Public MethodLog Accepts an entry for logging. Provides timer- or counter-controlled buffering of messages. Does not log itself directly, but calls the method abstract defined here WriteLog, in which the physical writing then takes place. Flows the buffer asynchronously to improve logging performance.
(Inherited from LoggerBase)
Protected MethodOrganiseLoggings Renames the log (DebugFile) after a defined period of time DebugFileArchivingInterval and deletes logs (DebugFiles) that are older than DebugFileArchiveLifetime. The calling process must take care of any locking of the debug file.
(Overwrites LoggerBaseOrganiseLoggings(TimeSpan, Int32))
Public MethodShow Can be overwritten to display the log; for text files, e.g. via output to the standard editor.
(Overwrites LoggerBaseShow)
Public MethodStop Must be called at the end of processing to stop the timer.
(Inherited from LoggerBase)
Protected MethodWriteLog Writes an entry to the log file, but is not recognised externally. directly; instead, the logger must be called as a viewer via enter its HandleInfoForLog method in the InfoController.
(Overwrites LoggerBaseWriteLog(String))
Back to the top
Remarks
Author: Erik Nagel, NetEti 08.03.2012 Erik Nagel: created 2014-03-15 Erik Nagel: Statistics implemented; Regex filter implemented. 2016-07-14 Erik Nagel: Exceptions are now logged in any case. 14.01.2018 Erik Nagel: Revised due to memory leaks (StringBuilder); output format optimised. 21.01.2022 Erik Nagel: _replaceRegex implemented. 06.11.2023 Erik Nagel: IShowable implemented.
See also