How to output all the sql of Ormlite in the debug mode

Hi
My service is used by mobile and i want to profiling my service when debugging.

I find ProfiledDbConnection can give me a good view to see the sql. I paste a url in the browser(get method) and then i can sea the report. But i don’t know if i use ajax(postman) or mobile client(mobile) to post a request, how do i see results.

And is there a flag i can check and then the sql of generating by Ormlite will output in the console? I can check the generation while developing.

Register your preferred Logging Provider so you can view your App Logs, and initialize the LogFactory with debugEnabled:true so you enable Debug logging.

My log is here
#if DEBUG
LogManager.LogFactory = new DebugLogFactory(debugEnabled: true);//or console log
#else
//Also runs log4net.Config.XmlConfigurator.Configure()
LogManager.LogFactory = new Log4NetFactory(configureLog4Net: true);
#endif

and i print Log.Debug(Db.GetLastSql());

But when i debug the service, i can not see sql in the output window of Visual Studio. while Log4NetFactory is ok, i can see log in the log file.

  1. Could you tell me where to find console output?
  2. I want to print Profiler details(include sql) in the log, could i do this.

Db.GetLastSql() doesn’t log anything, it just returns the last SQL Statement executed.

If you want to log to the Console register a ConsoleLogFactory, e.g:

LogManager.LogFactory = new ConsoleLogFactory(debugEnabled:true); 

But there is no Console Output when running in IIS, to see the logs you need to configure to use one of the logging providers, e.g: Log4Net.

Thank you. I will use Log4Net.

I want to print Profiler details(include sql) in the log, could i do this.

The debug logging shows everything that gets logged, i.e if you enable debugLogging:true OrmLite logs the executed SQL. The latest v4.0.43+ on MyGet also logs DB Params and SQL for INSERT/UPDATE/DELETE statements.

The MiniProfiler doesn’t log stats.