Class LogServiceBase
Based class for implementing test and non-test logging services. Destinations may fail and the message will be failed-over into another destination in the same logger as specified by 'failover' attribute of destination. This attribute is also present on service level. Cascading failover is not supported (failover of failovers). Another consideration is that messages get sent into destinations synchronously by internal thread so specifying too many destinations may limit overall LogService throughput. In complex scenarios consider using LogServiceDestination instead.
Inheritance
Implements
Inherited Members
Namespace: NFX.Log
Assembly: NFX.dll
Syntax
public abstract class LogServiceBase : ServiceWithInstrumentationBase<object>, IService, INamed, ILogImplementation, ILog, IApplicationComponent, ILocalizedTimeProvider, IDisposable, IConfigurable, IInstrumentable, IExternallyParameterized
Constructors
LogServiceBase()
Creates a new logging service instance
Declaration
protected LogServiceBase()
LogServiceBase(Service)
Creates a new logging service instance
Declaration
protected LogServiceBase(Service director = null)
Parameters
Type | Name | Description |
---|---|---|
Service | director |
Fields
m_Destinations
Declaration
protected LogServiceBase.DestinationList m_Destinations
Field Value
Type | Description |
---|---|
LogServiceBase.DestinationList |
m_InstrumentationEnabled
Declaration
protected bool m_InstrumentationEnabled
Field Value
Type | Description |
---|---|
System.Boolean |
Properties
ComponentCommonName
Declaration
public override string ComponentCommonName { get; }
Property Value
Type | Description |
---|---|
System.String |
Overrides
DefaultFailover
Sets destination name used for failover on the service-level if particular failing destination did not specify its specific failover
Declaration
[Config("$default-failover")]
[ExternalParameter(new string[]{"log"})]
public string DefaultFailover { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Destinations
Returns registered destinations. This call is thread safe
Declaration
public IEnumerable<Destination> Destinations { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Destination> |
DestinationsAreOptional
Indicates whether the service can operate without any destinations registered, i.e. some test loggers may not need any destinations to operate as they synchronously write to some buffer without any extra destinations
Declaration
public virtual bool DestinationsAreOptional { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
FailoverError
Returns last exception that happened during failover. This kind of exceptions is never propagated and always handled
Declaration
public Exception FailoverError { get; }
Property Value
Type | Description |
---|---|
System.Exception |
FailoverErrorDestination
Returns a destination that threw last exception that happened durng failover. This kind of exceptions is never propagated and always handled
Declaration
public Destination FailoverErrorDestination { get; }
Property Value
Type | Description |
---|---|
Destination |
InstrumentationBufferSize
Declaration
[Config]
[ExternalParameter(new string[]{"log", "instrumentation"})]
public int InstrumentationBufferSize { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
InstrumentationEnabled
Implements IInstrumentable
Declaration
[Config(Default = false)]
[ExternalParameter(new string[]{"log", "instrumentation"})]
public override bool InstrumentationEnabled { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
LastCatastrophy
Latches last problematic msg
Declaration
public Message LastCatastrophy { get; }
Property Value
Type | Description |
---|---|
Message |
LastError
Latches last problematic msg
Declaration
public Message LastError { get; }
Property Value
Type | Description |
---|---|
Message |
LastWarning
Latches last problematic msg
Declaration
public Message LastWarning { get; }
Property Value
Type | Description |
---|---|
Message |
Now
Returns localized log time
Declaration
public DateTime Now { get; }
Property Value
Type | Description |
---|---|
System.DateTime |
Methods
Destructor()
Declaration
protected override void Destructor()
Overrides
DoConfigure(IConfigSectionNode)
Declaration
protected override void DoConfigure(IConfigSectionNode node)
Parameters
Type | Name | Description |
---|---|---|
IConfigSectionNode | node |
Overrides
DoStart()
Declaration
protected override void DoStart()
Overrides
DoWaitForCompleteStop()
Declaration
protected override void DoWaitForCompleteStop()
Overrides
DoWrite(Message, Boolean)
Writes log message into log
Declaration
protected abstract void DoWrite(Message msg, bool urgent)
Parameters
Type | Name | Description |
---|---|---|
Message | msg | Message to write |
System.Boolean | urgent | Indicates that the logging service implementation must make an effort to write the message to its destinations urgently |
GetInstrumentationBuffer(Boolean)
Returns instrumentation buffer if instrumentation enabled
Declaration
public IEnumerable<Message> GetInstrumentationBuffer(bool asc)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | asc |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Message> |
Pulse()
Declaration
protected void Pulse()
RegisterDestination(Destination, Int32)
Adds a destination to this service active destinations. Negative index to append
Declaration
public void RegisterDestination(Destination dest, int atIdx = -1)
Parameters
Type | Name | Description |
---|---|---|
Destination | dest | |
System.Int32 | atIdx |
UnRegisterDestination(Destination)
Removes a destiantion from this service active destinations, returns true if destination was found and removed
Declaration
public bool UnRegisterDestination(Destination dest)
Parameters
Type | Name | Description |
---|---|---|
Destination | dest |
Returns
Type | Description |
---|---|
System.Boolean |
Write(Message)
Writes log message into log
Declaration
public void Write(Message msg)
Parameters
Type | Name | Description |
---|---|---|
Message | msg | Message to write |
Write(Message, Boolean)
Writes log message into log
Declaration
public void Write(Message msg, bool urgent)
Parameters
Type | Name | Description |
---|---|---|
Message | msg | Message to write |
System.Boolean | urgent | Indicates that the logging service implementation must make an effort to write the message to its destinations urgently |
Write(MessageType, String, Boolean, String, String)
Writes log message into log
Declaration
public void Write(MessageType type, string text, bool urgent, string topic = null, string from = null)
Parameters
Type | Name | Description |
---|---|---|
MessageType | type | |
System.String | text | |
System.Boolean | urgent | |
System.String | topic | |
System.String | from |
Write(MessageType, String, String, String)
Writes log message into log
Declaration
public void Write(MessageType type, string text, string topic = null, string from = null)
Parameters
Type | Name | Description |
---|---|---|
MessageType | type | |
System.String | text | |
System.String | topic | |
System.String | from |