SpringCard LibCs for .NET  18.10.10
A set of utilities to simplify the development of .NET application
SpringCard.LibCs.Logger Class Reference

Utility to log execution information on the console, the trace or debug output, the system event collector (Windows or Syslog) or a remote GrayLog server. More...

Classes

class  LoggerDebugListener
 
class  LoggerTraceListener
 

Public Types

enum  Level {
  Level.None = -1, Level.Fatal, Level.Error, Level.Warning,
  Level.Info, Level.Trace, Level.Debug, Level.All
}
 The level of details in the output or log. More...
 

Public Member Functions

delegate void LogCallbackDelegate (Level level, string message)
 

Static Public Member Functions

static void CaptureTrace ()
 
static void CaptureDebug ()
 
static Level IntToLevel (int intLevel)
 Translate a numeric value into a valid Level enum value.
 
static Level StringToLevel (string strLevel)
 Translate a text value into a valid Level enum value.
 
static void LoadConfigFromRegistry (string CompanyName, string ProductName)
 Load the Logger settings from the application's registry branch.
 
static void ReadArgs (string[] args)
 Load the Logger settings from the program's command line.
 
static void OpenSysLog (SysLog.Facility facility, string hostName, string applicationName, string serverAddr, int serverPort=514, bool useRfc5424=false)
 Configure the Logger to send its messages to a SysLog server.
 
static void OpenSysLog (SysLog.Facility facility, Level level, string applicationName, string serverAddr, int serverPort=514, bool useRfc5424=false)
 Configure the Logger to send its messages to a SysLog server.
 
static void OpenSysLog (SysLog.Facility facility, string ServerAddr, int ServerPort=514, bool useRfc5424=false)
 Configure the Logger to send its messages to a SysLog server.
 
static void OpenSysLog (SysLog.Facility facility, Level level, string ServerAddr, int ServerPort=514, bool useRfc5424=false)
 Configure the Logger to send its messages to a SysLog server.
 
static void OpenSysLog (string ServerAddr, int ServerPort=514, bool useRfc5424=false)
 Configure the Logger to send messages to a SysLog server.
 
static void OpenSysLog (Level level, string ServerAddr, int ServerPort=514, bool useRfc5424=false)
 Configure the Logger to send its messages to a SysLog server.
 
static void OpenGelf_SpringCardNet (Level level, string hostName, string applicationName)
 Configure the Logger to send its messages to SpringCard's GrayLog server. More...
 
static void OpenGelf_SpringCardNet (Level level, string applicationName)
 Configure the Logger to send its messages to SpringCard's GrayLog server. More...
 
static void OpenGelf (Level level, string hostName, string applicationName, string serverName, int serverPort=2202)
 Configure the Logger to send its messages to a GrayLog server.
 
static void OpenGelf (Level level, string applicationName, string serverAddr, int serverPort=2202)
 Configure the Logger to send its messages to a GrayLog server.
 
static void OpenGelf (Level level, string serverAddr, int serverPort=2202)
 Configure the Logger to send its messages to a GrayLog server.
 
static void SetGelfConstant (string Name, string Value)
 Set a GrayLog constant parameter.
 
static void OpenLogFile (string fileName, bool useDate=false)
 Configure the Logger to send its messages to a file.
 
static void OpenLogFile (Level level, string fileName, bool useDate=false)
 Configure the Logger to send its messages to a file.
 
static void OpenEventLog (string log, string source)
 Configure the Logger to send its messages to Windows' event log.
 
static void OpenEventLog (Level level, string log, string source)
 Configure the Logger to send its messages to Windows' event log.
 
static void Debug (string message)
 Log a Debug-level message.
 
static void Debug (string message, params object[] args)
 Log a Debug-level message.
 
static void Trace (string message)
 Log a Trace-level message.
 
static void Trace (string message, params object[] args)
 Log a Trace-level message.
 
static void Info (string message)
 Log an Info-level message.
 
static void Info (string message, params object[] args)
 Log an Info-level message.
 
static void Warning (string message)
 Log a Warning-level message.
 
static void Warning (string message, params object[] args)
 Log a Warning-level message.
 
static void Error (string message)
 Log an Error-level message.
 
static void Error (string message, params object[] args)
 Log an Error-level message.
 
static void Fatal (string message)
 Log a Fatal-level message.
 
static void Fatal (string message, params object[] args)
 Log a Fatal-level message.
 
static void Log (Level level, string message)
 Log a message.
 
static void Log (Level level, string message, params object[] args)
 Log a message.
 

Static Public Attributes

static Level DebugLevel = Level.Trace
 Level of details directed to Visual Studio's debug window if the program (or the library) is compiled with DEBUG active, and is launched from the IDE.
 
static Level TraceLevel = Level.Trace
 Level of details directed to Visual Studio's output window if the program (or the library) is compiled with TRACE active, and is launched from the IDE.
 
static LogCallbackDelegate LogCallback = null
 
static Level ConsoleLevel = Level.None
 Level of details directed the console (stdout)
 
static bool ConsoleShowTime = true
 Include the time of execution in the console output.
 
static bool ConsoleShowContext = true
 Include the class and method (if this information is available) in the console output.
 
static bool ConsoleUseColors = true
 Use colors to decorate the console output.
 
static Level SyslogLogLevel = Level.Info
 
static Level GelfLogLevel = Level.Warning
 
static Level FileLogLevel = Level.Info
 
static Level EventLogLevel = Level.Info
 

Properties

static bool ConsoleOnly [set]
 Short cut to disable all log outputs -but console- if the program is undergoing unit tests.
 

Detailed Description

Utility to log execution information on the console, the trace or debug output, the system event collector (Windows or Syslog) or a remote GrayLog server.

Member Enumeration Documentation

◆ Level

The level of details in the output or log.

Warning
Debug level may leak sensitive information!
Enumerator
None 

Completely disable the log

Fatal 

Log Fatal messages only, i.e. unrecoverable errors or exceptions that leads to the termination of the program

Error 

Same as Fatal + also log Error messages, for instance errors or exceptions in the program itself

Warning 

Same as Error + also log Warning messages, for instance recoverable errors in system calls or user-related errors in the program

Info 

Same as Warning + also log Info messages, to see how the program behaves

Trace 

Same as Info + also log Trace messages to follow the execution flow

Debug 

Same as Trace + also log Debug messages, with detailed information regarding the execution flow and parameters

All 

Log all messages (same as Debug)

Member Function Documentation

◆ OpenGelf_SpringCardNet() [1/2]

static void SpringCard.LibCs.Logger.OpenGelf_SpringCardNet ( Level  level,
string  hostName,
string  applicationName 
)
static

Configure the Logger to send its messages to SpringCard's GrayLog server.

Warning
Do not use this feature in your own application!

◆ OpenGelf_SpringCardNet() [2/2]

static void SpringCard.LibCs.Logger.OpenGelf_SpringCardNet ( Level  level,
string  applicationName 
)
static

Configure the Logger to send its messages to SpringCard's GrayLog server.

Warning
Do not use this feature in your own application!

The documentation for this class was generated from the following file: