Class SoLogger
Summary description for SoLogger.
Inherited Members
Namespace: SuperOffice.Diagnostics
Assembly: SoCore.dll
Syntax
[SoInject("Database")]
public sealed class SoLogger
Constructors
SoLogger(ILoggerFactory)
Dependency injection constructor.
Declaration
public SoLogger(ILoggerFactory loggerFactory)
Parameters
Type | Name | Description |
---|---|---|
ILoggerFactory | loggerFactory | Logger factory ready to make new loggers on demand |
Properties
Logger
Get the singleton instance of the logger class
Declaration
public static SoLogger Logger { get; }
Property Value
Type | Description |
---|---|
SoLogger |
Methods
BeginScope(String, String, Object[])
Open a logging scope
Declaration
public static IDisposable BeginScope(string category, string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
String | category | |
String | message | Summary message |
Object[] | args | Details for message |
Returns
Type | Description |
---|---|
IDisposable | Disposable scope. Dispose to close scope. |
BeginScope<T>(String, Object[])
Open a logging scope
Declaration
public static IDisposable BeginScope<T>(string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
String | message | Summary message |
Object[] | args | Details for message |
Returns
Type | Description |
---|---|
IDisposable | Disposable scope. Dispose to close scope. |
Type Parameters
Name | Description |
---|---|
T |
Count(String, Dictionary<String, Double>)
Count a multiple values
Declaration
public static void Count(string eventName, Dictionary<string, double> metrics)
Parameters
Type | Name | Description |
---|---|---|
String | eventName | |
Dictionary<String, Double> | metrics |
Count(String, NameValueCollection, Dictionary<String, Double>)
Count a multiple values
Declaration
public static void Count(string eventName, NameValueCollection env, Dictionary<string, double> metrics)
Parameters
Type | Name | Description |
---|---|---|
String | eventName | |
NameValueCollection | env | |
Dictionary<String, Double> | metrics |
Count(String, String, Double)
Count a single value
Declaration
public static void Count(string eventName, string counterName, double counterValue)
Parameters
Type | Name | Description |
---|---|---|
String | eventName | |
String | counterName | |
Double | counterValue |
Count(String, String[])
Count 1 for these names.
Declaration
public static void Count(string eventName, params string[] counterNames)
Parameters
Type | Name | Description |
---|---|---|
String | eventName | |
String[] | counterNames |
Count(String, (String, Double)[])
Count a multiple values without having to construct a dictionary first
Declaration
public static void Count(string eventName, params (string, double)[] pairs)
Parameters
Type | Name | Description |
---|---|---|
String | eventName | |
ValueTuple<String, Double>[] | pairs |
GetEnvironmentInfo()
Get a name/value collection of environmental information, from all subscribers to our event. Also add any hard-set additional values.
Declaration
public NameValueCollection GetEnvironmentInfo()
Returns
Type | Description |
---|---|
NameValueCollection |
GetLogger(String)
Declaration
public ILogger GetLogger(string categoryName)
Parameters
Type | Name | Description |
---|---|---|
String | categoryName |
Returns
Type | Description |
---|---|
ILogger |
GetLogger(Type)
Declaration
public ILogger GetLogger(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type |
Returns
Type | Description |
---|---|
ILogger |
GetLogger<T>()
Declaration
public ILogger<T> GetLogger<T>()
Returns
Type | Description |
---|---|
ILogger<T> |
Type Parameters
Name | Description |
---|---|
T |
LogCritical<T>(Exception, String, Object[])
Create and log an event of type Critical to the logging system.
Declaration
public static void LogCritical<T>(Exception exception, string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
Exception | exception | Exception being thrown |
String | message | Log message, including {placeholders} for arguments. |
Object[] | args | Parameters to message |
Type Parameters
Name | Description |
---|---|
T |
LogCritical<T>(String, Object[])
Create and log an event of type Critical to the logging system.
Declaration
public static void LogCritical<T>(string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
String | message | Log message, including {placeholders} for arguments. |
Object[] | args | Parameters to message |
Type Parameters
Name | Description |
---|---|
T |
LogDebug(String, String, Object[])
Create and log an event of type Debug to the logging system.
Declaration
public static void LogDebug(string categoryName, string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
String | categoryName | Log category - usually the type name |
String | message | Log message, including {placeholders} for arguments. |
Object[] | args | Parameters to message |
LogDebug<T>(Exception, String, Object[])
Create and log an event of type Debug to the logging system.
Declaration
public static void LogDebug<T>(Exception exception, string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
Exception | exception | Exception being thrown |
String | message | Summary message |
Object[] | args | Details for message |
Type Parameters
Name | Description |
---|---|
T |
LogDebug<T>(String, Object[])
Create and log an event of type Debug to the logging system.
Declaration
public static void LogDebug<T>(string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
String | message | Summary message |
Object[] | args | Parameters to message |
Type Parameters
Name | Description |
---|---|
T |
LogEntry(LogEntryInfo, Boolean, Boolean)
Log an entry to the logging system. Checks the ConfigFile.Diagnostics Log properties to determine if a particular entry should be included.
Declaration
public void LogEntry(LogEntryInfo entry, bool lightLogOutput, bool force = false)
Parameters
Type | Name | Description |
---|---|---|
LogEntryInfo | entry | The entry to log. |
Boolean | lightLogOutput | If lightLogOutput is true, stack trace and environment is not logged as part of the log entry. |
Boolean | force | Force the entry to be logged, even if the type is ignored |
LogError(SoExceptionInfo)
Log en exception as an error.
Declaration
[Obsolete("old - use new LogError<T> instead", false)]
public static void LogError(SoExceptionInfo ex)
Parameters
Type | Name | Description |
---|---|---|
SoExceptionInfo | ex | Exception to report. |
LogError(Exception)
Log en exception as an error.
Declaration
[Obsolete("old - use new LogError<T> instead", false)]
public static void LogError(Exception ex)
Parameters
Type | Name | Description |
---|---|---|
Exception | ex | Exception to report. |
LogError(String, String, Object[])
Create and log an event of type Warning to the logging system.
Declaration
public static void LogError(string categoryName, string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
String | categoryName | Log category - usually the type name |
String | message | Log message, including {placeholders} for arguments. |
Object[] | args | Parameters to message |
LogError(Type, String, String)
Create and log an event of type Error to the logging system. This method is a shorthand for creating a log entry and logging it. Use the LogEntry method if you need the more general version.
Declaration
[Obsolete("old - use new LogInformation<T> instead", false)]
public static void LogError(Type sourceType, string message, string details)
Parameters
Type | Name | Description |
---|---|---|
Type | sourceType | Type of object where the event happened |
String | message | Summary message |
String | details | Detailed message |
LogError<T>(Exception, String, Object[])
Create and log an event of type Error to the logging system.
Declaration
public static void LogError<T>(Exception exception, string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
Exception | exception | Exception being thrown |
String | message | Log message, including {placeholders} for arguments. |
Object[] | args | Parameters to message |
Type Parameters
Name | Description |
---|---|
T |
LogError<T>(String, Object[])
Create and log an event of type Warning to the logging system.
Declaration
public static void LogError<T>(string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
String | message | Log message, including {placeholders} for arguments. |
Object[] | args | Parameters to message |
Type Parameters
Name | Description |
---|---|
T |
LogException(EventLogEntryType, Exception, Boolean)
Log an exception. Logging will be done to a log file, debugger trace, and SuperOffice crash log service depending on the options set in the config file.
Declaration
[Obsolete("Use LogError<T>(ex) instead", false)]
public void LogException(EventLogEntryType logType, Exception exception, bool lightLogOutput = false)
Parameters
Type | Name | Description |
---|---|---|
EventLogEntryType | logType | |
Exception | exception | |
Boolean | lightLogOutput |
LogExceptionError(Exception, String, Object[])
Create and log an event of type Error to the logging system.
Declaration
public static void LogExceptionError(Exception exception, string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
Exception | exception | Exception being thrown |
String | message | Summary message |
Object[] | args | Details for message |
LogExceptionWarning(Exception, String, Object[])
Create and log an event of type Warning to the logging system.
Declaration
public static void LogExceptionWarning(Exception exception, string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
Exception | exception | Exception being thrown |
String | message | Summary message |
Object[] | args | Details for message |
LogFailure(Exception, String, Object[])
Create and log an event of type Error to the logging system, tagged as FailureAudit.
Declaration
public static void LogFailure(Exception exception, string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
Exception | exception | Exception being thrown |
String | message | Log message, including {placeholders} for arguments. |
Object[] | args | Parameters to message |
LogInformation(String, String, Object[])
Create and log an event of type Information to the logging system.
Declaration
public static void LogInformation(string categoryName, string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
String | categoryName | Log category - usually the type name |
String | message | Log message, including {placeholders} for arguments. |
Object[] | args | Parameters to message |
LogInformation(Type, String, String)
Create and log an event of type Information to the logging system. This method is a shorthand for creating a log entry and logging it. Use the LogEntry method if you need the more general version.
Declaration
[Obsolete("old - use new LogInformation<T> instead")]
public static void LogInformation(Type sourceType, string message, string details)
Parameters
Type | Name | Description |
---|---|---|
Type | sourceType | Type of object where the event happened |
String | message | Summary message |
String | details | Detailed message |
LogInformation(Type, String, String, Boolean)
Create and log an event of type Information to the logging system. This method is a shorthand for creating a log entry and logging it. Use the LogEntry method if you need the more general version.
Declaration
[Obsolete("old - use new LogInformation<T> instead", false)]
public static void LogInformation(Type sourceType, string message, string details, bool lightLogOutput)
Parameters
Type | Name | Description |
---|---|---|
Type | sourceType | Type of object where the event happened |
String | message | Summary message |
String | details | Detailed message |
Boolean | lightLogOutput | If lightLogOutput is true, stack trace and environment is not logged as part of the log entry. |
LogInformation<T>(Exception, String, Object[])
Create and log an event of type Information to the logging system.
Declaration
public static void LogInformation<T>(Exception exception, string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
Exception | exception | Exception being thrown |
String | message | Summary message |
Object[] | args | Details for message |
Type Parameters
Name | Description |
---|---|
T |
LogInformation<T>(String, Object[])
Create and log an event of type Information to the logging system.
Declaration
public static void LogInformation<T>(string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
String | message | Log message, including {placeholders} for arguments. |
Object[] | args | Parameters to message |
Type Parameters
Name | Description |
---|---|
T |
LogServiceCallToFile(String)
Log a service layer call to file
Declaration
public static void LogServiceCallToFile(string serviceInformation)
Parameters
Type | Name | Description |
---|---|---|
String | serviceInformation |
LogSuccess(Exception, String, Object[])
Create and log an event of type Information to the logging system, tagged as SuccessAudit.
Declaration
public static void LogSuccess(Exception exception, string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
Exception | exception | Exception being thrown |
String | message | Log message, including {placeholders} for arguments. |
Object[] | args | Parameters to message |
LogTrace(String, String, Object[])
Create and log an event of type Trace to the logging system.
Declaration
public static void LogTrace(string categoryName, string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
String | categoryName | Log category - usually the type name |
String | message | Log message, including {placeholders} for arguments. |
Object[] | args | Parameters to message |
LogTrace<T>(String, Object[])
Create and log an event of type Trace to the logging system.
Declaration
public static void LogTrace<T>(string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
String | message | Log message, including {placeholders} for arguments. |
Object[] | args |
Type Parameters
Name | Description |
---|---|
T |
LogWarning(Exception)
Log an exception as a warning
Declaration
[Obsolete("old - use new LogWarning<T> instead")]
public static void LogWarning(Exception ex)
Parameters
Type | Name | Description |
---|---|---|
Exception | ex | Exception to log as warning. |
LogWarning(String, String, Object[])
Create and log an event of type Warning to the logging system.
Declaration
public static void LogWarning(string categoryName, string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
String | categoryName | Log category - usually the type name |
String | message | Log message, including {placeholders} for arguments. |
Object[] | args | Parameters to message |
LogWarning(Type, String, String)
Create and log an event of type Warning to the logging system. This method is a shorthand for creating a log entry and logging it. Use the LogEntry method if you need the more general version.
Declaration
[Obsolete("old - use new LogWarning<T> instead")]
public static void LogWarning(Type sourceType, string message, string details)
Parameters
Type | Name | Description |
---|---|---|
Type | sourceType | Type of object where the event happened |
String | message | Summary message |
String | details | Detailed message |
LogWarning<T>(Exception, String, Object[])
Create and log an event of type Warning to the logging system.
Declaration
public static void LogWarning<T>(Exception exception, string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
Exception | exception | Exception being thrown |
String | message | Summary message |
Object[] | args | Details for message |
Type Parameters
Name | Description |
---|---|
T |
LogWarning<T>(String, Object[])
Create and log an event of type Warning to the logging system.
Declaration
public static void LogWarning<T>(string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
String | message | Log message, including {placeholders} for arguments. |
Object[] | args | Parameters to message |
Type Parameters
Name | Description |
---|---|
T |
PopulateEnvironmentInfo(LogEntryInfo)
Populate environment information for a log entry.
Declaration
public void PopulateEnvironmentInfo(LogEntryInfo entry)
Parameters
Type | Name | Description |
---|---|---|
LogEntryInfo | entry | The entry to populate environment information on. |
PopulateEnvironmentInfo(NameValueCollection)
Populate environment information for a log entry.
Declaration
public void PopulateEnvironmentInfo(NameValueCollection values)
Parameters
Type | Name | Description |
---|---|---|
NameValueCollection | values | Collection to hold the values. |
SetILoggerFactory(ILoggerFactory)
Inject your own factory, overriding any that might have been provided by a ILoggerProviderPlugin plugin
Declaration
public void SetILoggerFactory(ILoggerFactory loggerFactory)
Parameters
Type | Name | Description |
---|---|---|
ILoggerFactory | loggerFactory | ILogger object creator |
SetPermanentAdditionalValue(String, String)
Set one named value to be added to any logged events. This name/value will remain valid until manually reset or changed.
Declaration
public static void SetPermanentAdditionalValue(string name, string value)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of item |
String | value | Value of item |
SetPermanentAdditionalValues(String[], String[])
Set an array of named values to be added to any logged events. These names/values will remain valid until manually reset or changed.
Declaration
public static void SetPermanentAdditionalValues(string[] names, string[] values)
Parameters
Type | Name | Description |
---|---|---|
String[] | names | Names of items |
String[] | values | Values of items |
StartOperation(String, String[])
Log an operation
Declaration
public static IDisposable StartOperation(string operationname, params string[] args)
Parameters
Type | Name | Description |
---|---|---|
String | operationname | Name of operation being traced |
String[] | args | Additional strings to add to trace (optional) |
Returns
Type | Description |
---|---|
IDisposable | an operation tracer. Dispose it to signal end of operation |