Log message.

Namespace: Dapfor.Net.Diagnostics
Assembly: Dapfor.Net (in Dapfor.Net.dll) Version: (


public class LogMessage
Visual Basic
Public Class LogMessage
Visual C++
public ref class LogMessage
type LogMessage =  class end


.Net Logger is a thread-safe system for storing and representation of various log messages. Besides text messages, programmer can associate with data any object that can carry extended information. For example, it can be a price snapshot, quantity value of a product or a pointer to the product object. When a programmer analyzes a log file, he can not just review messages, but also vizw product characteristics that can be dynamically changed. There are several possibilities of object association:

  • Creating a hierarchical representation of associated object's properties and its values
  • Displaying a list of properties with its values in a popup tooltip
  • Transferring an object associated with message to the .Net Inspector for detailed viewing and editing
 Copy imageCopy
public enum Way

public sealed class Quote
    private readonly long qty;
    private readonly decimal price;
    private readonly Way way;

    public Quote(long qty, decimal price, Way way)
        this.qty = qty;
        this.price = price;
        this.way = way;

    public long Qty
        get { return qty; }
    public decimal Price
        get { return price; }
    public Way Way
        get { return way; }

Logger.Info("Hey, I just got a new price", new Quote(31911, 41, Way.Buy));

How much memory does the .Net Logger consume?

The logging system is divided by two parts:

  • The logger that stores a list of messages
  • The viewer that displays them

The logging system by itself doesn't consumes a lot of memory. On the average, memory consumption does not exceed 40 bytes per message. In other words, it consumes almost 40 MB for 1 million of lines. Data logging occurs like this:

 Copy imageCopy
Logger.Info("some message");

Memory consumption of the Viewer is about 150-160 bytes per message. The maximum quantity of the lines in the grid can be limited via LogViewer.MaxRowCount = MAX_VALUE. If the MAX_VALUE is exceeded, older messages are not displayed.

Besides that, memory consumption depends on size and type of object that can be stored together with the log entry. On the average, for simple objects this size equals 30-40 bytes per message. From the practical point of view, when the number of rows is limited to 100,000, memory consumption should not exceed 60-100 MB per 1,000,000 messages.

Inheritance Hierarchy


See Also