DHTMLX Docs & Samples Explorer

Error Handling and Logging

During development phase, we strongly recommend to use server side logs, which can be enabled as

        //attach begin and end events to enable and disable logging in them
        connector.Begin += new EventHandler(connector_Begin);
        connector.End += new EventHandler(connector_End);
 
        //we will store log content here
        private StringBuilder _LogContent = new StringBuilder();
 
        void connector_End(object sender, EventArgs e)
        {
            Log.Enabled = false;//stop logging
        }
 
        void connector_Begin(object sender, EventArgs e)
        {
            //enable logging and add listener to it
            Log.Enabled = true;
            Log.Listeners.Add(new TextWriterTraceListener(new StringWriter(this._LogContent)));
        }

Log object is wrapper over System.Diagnostics.Trace class, thus you can use standard .NET Framework techniques for tracing. To start logging you need to set Log's Enabled property to true and add one or more listeners to it's Listeners collection. You can read more about TraceListeners here . Example above writes log messages into the local variable (_LogContent). Alternatively you can use console or file system as messages destination. What's more, you can see log messages in Microsoft Visual Studio's Output window (“Show output from: Debug”) when you run application in debug mode.

Dataprocessor logging

Dataprocessor has its own client side logger, which can be enabled by including one additional js file - dhtmlxdataprocessor_debug.js

Adding custom records to the log

During development , you may have need to write some custom data to the log ( can be useful for custom server side events ), in such case you can use default log as

         Log.WriteLine(this, "Message");

First parameter is reference to the object that is writing message to the log. Second one is message itself.