Error logging

To assist you in developing your Coden tools a set of log files are written out during Coden usage. Depending on the installation, these files can be found inside <LocalAppData>\Ephere\Library\logs directory.

Most interesting is the Coden.log file, which records all activity of your Coden plugins including any unhandled exceptions. You may find other log files in this directory. These logs reflect operations of other components of Coden and as such are of less interest.

Writing to the log

There are a few ways to output messages to the log file. You may find these useful to track and display extra information from inside your plugin for debugging or informative purposes. If your clients experience issues with your tools you may ask them to collect the Coden.log file and send it to you for analysis. Consider the following example:

// System.Diagnostics namespace contains methods useful for logging
using System.Diagnostics;
 
namespace MyPlugins
{
	public static partial class Commands
	{
		public static bool MyCommand()
		{
			// Writes a message to the host application's UI and logs it to Coden.log
			Trace.TraceInformation( "Some useful message" );
 
			// Writes a warning message to the host application's UI and logs it to Coden.log
			Trace.TraceWarning( "This is a warning" );
 
			// Writes an error message to the host application's UI and logs it to Coden.log
			int myNumber = 1;
			Trace.TraceError( string.Format( "An error has occurred: {0}", myNumber ) );
 
			return true;
		}
	}
}

We first include the System.Diagnostics namespace to be able to reference the Trace class. We are then able to use the TraceInformation, TraceWarning, and TraceError methods, depending on the current need, to log the appropriate information. This information will be presented to the user inside the current host application's GUI and also written to Coden.log file for reference.