Class AbstractLogger
Abstract implementation for ILogger, which safes some time. In general you will only need to implement Write (without exception) as: 1) WriteLine in calls Write after appending a newline. 2) WriteLine with Exception calls WriteLine with the template/parameters and again with the Exception.ToString()
Inheritance
Inherited Members
Namespace:Dapplo.Log
Assembly:Dapplo.Log.dll
Syntax
public class AbstractLogger : ILogger, ILoggerConfiguration
Properties
| Improve this Doc View SourceDateTimeFormat
Timestamp format which is used in the output, when outputting the LogInfo details
Declaration
public string DateTimeFormat { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Implements
| Improve this Doc View SourceLogLevel
Use this to specify the LogLevels enum
Declaration
public virtual LogLevels LogLevel { get; set; }
Property Value
Type | Description |
---|---|
LogLevels |
Implements
| Improve this Doc View SourceLogLineFormat
Default line format for loggers which use the DefaultFormatter. The first argument is the LogInfo, the second the message + parameters formatted
Declaration
public string LogLineFormat { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Implements
| Improve this Doc View SourceUseShortSource
Defines if the Source is written like d.l.LoggerTest (default) or Dapplo.Log.LoggerTest
Declaration
public bool UseShortSource { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Implements
Methods
| Improve this Doc View SourceConfigure(ILoggerConfiguration)
Configure the logger with the supplied configuration, values are copied.
Declaration
public virtual void Configure(ILoggerConfiguration configuration)
Parameters
Type | Name | Description |
---|---|---|
ILoggerConfiguration | configuration | ILoggerConfiguration |
Implements
| Improve this Doc View SourceFormat(LogInfo, String, Object[])
This function can be changed to format the line message differently First argument is the LogInfo, second the messageTemplate, third the parameters
Declaration
public virtual string Format(LogInfo logInfo, string messageTemplate, params object[] logParameters)
Parameters
Type | Name | Description |
---|---|---|
LogInfo | logInfo | |
System.String | messageTemplate | |
System.Object[] | logParameters |
Returns
Type | Description |
---|---|
System.String |
Implements
| Improve this Doc View SourceIsLogLevelEnabled(LogLevels, LogSource)
Test if a certain LogLevels enum is enabled, optionally the LogSource for which this is requested is supplied and can be used.
Declaration
public virtual bool IsLogLevelEnabled(LogLevels logLevel, LogSource logSource = null)
Parameters
Type | Name | Description |
---|---|---|
LogLevels | logLevel | LogLevels enum |
LogSource | logSource | optional LogSource |
Returns
Type | Description |
---|---|
System.Boolean | true if this is enabled |
Implements
| Improve this Doc View SourceReplacedWith(ILogger)
Override this if you need to move your content into a different logger which replaces "you"
Declaration
public virtual void ReplacedWith(ILogger newLogger)
Parameters
Type | Name | Description |
---|---|---|
ILogger | newLogger | ILogger |
Implements
| Improve this Doc View SourceWrite(LogInfo, String, Object[])
Write a message with parameters to the logger
Declaration
public virtual void Write(LogInfo logInfo, string messageTemplate, params object[] logParameters)
Parameters
Type | Name | Description |
---|---|---|
LogInfo | logInfo | LogInfo |
System.String | messageTemplate | string with the message template |
System.Object[] | logParameters | object array with the parameters for the template |
Implements
| Improve this Doc View SourceWriteLine(LogInfo, Exception, String, Object[])
WriteLine with Exception calls WriteLine with messageTemplate / logParameters and WriteLine with the exception as string
Declaration
public virtual void WriteLine(LogInfo logInfo, Exception exception, string messageTemplate = null, params object[] logParameters)
Parameters
Type | Name | Description |
---|---|---|
LogInfo | logInfo | LogInfo |
System.Exception | exception | Exception |
System.String | messageTemplate | string with the message template |
System.Object[] | logParameters | object array with the parameters for the template |
Implements
| Improve this Doc View SourceWriteLine(LogInfo, String, Object[])
WriteLine, default wraps to write, passes a message with parameters to the logger and appends a newline
Declaration
public virtual void WriteLine(LogInfo logInfo, string messageTemplate, params object[] logParameters)
Parameters
Type | Name | Description |
---|---|---|
LogInfo | logInfo | LogInfo |
System.String | messageTemplate | string with the message template |
System.Object[] | logParameters | object array with the parameters for the template |