#1 2016-03-19 08:51:31

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

How to let mORMot log all executed SQL statements?

Hi ab,

How to have all SQL statements executed by the framework to be logged? I tried several approach, but failed:

  //TSynLog.Family.Level := LOG_VERBOSE; //I thought this will work but it's not.

  TSynLog.Family.Level := [sllNone, sllInfo, sllDebug, sllTrace, sllWarning, sllError,
    sllEnter, sllLeave,
    sllLastError, sllException, sllExceptionOS, sllMemory, sllStackTrace,
    sllFail, sllSQL, sllCache, sllResult, sllDB, sllHTTP, sllClient, sllServer,
    sllServiceCall, sllServiceReturn, sllUserAuth,
    sllCustom1, sllCustom2, sllCustom3, sllCustom4, sllNewRun,
    sllDDDError, sllDDDInfo, sllMonitoring]; //not working...

  TSynLog.Family.EchoToConsole := [sllSQL]; //not working...

  //my other settings if they are useful here:
  TSynLog.Family.AutoFlushTimeOut := 10;
  TSynLog.Family.OnArchive := EventArchiveZip;
  TSynLog.Family.ArchiveAfterDays := 7; // archive after 7 day

  TSynLog.Family.DestinationPath := GetServerLogsFolder;
  ForceDirectories(TSynLog.Family.DestinationPath);

I use the sqlite db. I serached all over the web but was not lucky, so post the question here.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#2 2016-03-19 09:07:27

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,544
Website

Re: How to let mORMot log all executed SQL statements?

I declare my own inherited class (not necessary)

type
  TubLog = class(TSQLLog)
  protected
  ....
  end;

declare a global variable

var
  ubLog: TSynLogClass = TubLog;

reassign both mORMOt loggin class to my instance

initialization
  SynDB.SynDBLog := ubLog;
  mORMot.SQLite3Log := ubLog;

And when during application startup

with ubLog.Family do begin
  ...
  Level := serverConfig.logging.levels; // you need at last sllDB, sllSQL here 
end;

Offline

#3 2016-03-21 08:01:21

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: How to let mORMot log all executed SQL statements?

Thanks MPV! I'll try and let you know the result smile


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

Board footer

Powered by FluxBB