What is the Logger and what is for?

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 view 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

It is important to mention, that the logger enables detailed viewing of state of whole application or its most important parts at the logging time.


Below is the code that demonstrates the simplicity and features of the logging system.

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:

  1. The logger that stores a list of messages
  2. 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:

Logger.Info("some message");

It doesn't mean that memory consumption will increase proportionally to the number of code line invocation. The compiler creates only one copy  of a message object, however it doesn't increase proportionally to the number of references to this object.

The difference may be substantial when the following code line is invoked:

Logger.Info("some message" + i);

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,  emory 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.

License: The .Net Logger component is available to owners of .Net Suite user license.