How to turn the logging on? (ASP.NET Edition)
Last modified:
Assign an instance of the StreamLog class to the queryBuilder.Log property.
public void SetLogger() { var log = new StreamLog(new FileStream(@"c:\tmp\Log", FileMode.Create, FileAccess.Write)); var qb = QueryBuilderStore.Get(); qb.Log = log; // log the QueryBuilder, SqlContext, MetadataProvider, SyntaxProvider activity // OR AqbHandler.Log = log; // in addition to the above-mentioned activity, will log all requests from clients to the server }
You can create your own class implementing the ILog interface to write messages to log. It can write them to a simple text file writer, or you can use a logging library like the "log4net" assembly.
using ActiveQueryBuilder.Web.Server.Handlers; using log4net; public class MvcApplication : HttpApplication { protected void Application_Start() { // do the needful BaseHandler.Log = new Logger(); } } public class Logger : ActiveQueryBuilder.Core.ILog { private static readonly ILog Log = LogManager.GetLogger("Logger"); public void Trace(string message) { Log.Info(message); } public void Warning(string message) { Log.Warn(message); } public void Error(string message) { Log.Error(message); } public void Error(Exception ex, string message) { Log.Error(message, ex); } }
You can simply put a breakpoint in the Error method to catch the exception details in the IDE.