Quantcast
Viewing all articles
Browse latest Browse all 19

Updated Wiki: Logging

HSS Core Logging

The Logging library includes a .NET Service that writes entries to either the local machine event log or a database table.

When you install the HSS Core Framework, the Logging Service is installed for you and defaults to logging to the local machine event log.
If you want to log to a database, you can run the HSS Log Database Wizard which will create the HSSLOG database for you. It supports
installing into an existing database, or creating a new database. Also supports SqlExpress or Sql Server.

Once configured, you add a reference to the HSS.Core.dll and then call...

HSS.Logging.Log.WriteEntry("message", EventLogEntryType.Information);
There are several overrides and additional helper methods that make it super convenient to write different types of messages to the log. Including
support for adding attachments to the entry when logging to the database.

Additionally, from your application initialization, you can designate the default application name, user name and entry formatter.

// Configure Logging
Log.DefaultApplicationName = "Your App";
Log.DefaultUserName = "System";
Log.Formatter = new CustomFormatter();

///<summary>/// Custom Log Entry Formatter///</summary>publicclass CustomFormatter
{
    // Format exception entriespublicvoid FormatException(Exception ex, HSS.Logging.LogEntry entry, HSS.Logging.ILog log)

    // Format non exception entriespublicvoid Format(HSS.Logging.LogEntry entry, HSS.Logging.ILog log)
}

Viewing all articles
Browse latest Browse all 19

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>