#1 2013-02-03 13:36:51

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Logging to the console

For debugging purposes, it could be very handy to output the logging content to a console window. It enables interactive debugging of a Client-Server process, for instance: you can interact with the Client, then look in real time at the server console window, and inspect which requests are processed, without the need to open the log file.

The EchoToConsole property enable you to select which events are to be echoed on the console (perhaps you expect only errors to appear, for instance).

with TSQLLog.Family do begin
    Level := LOG_VERBOSE;
    EchoToConsole := LOG_VERBOSE; // log all events to the console
  end;

Depending on the events, colors will be used to write the corresponding information. Errors will be displayed as light red, for instance.

Note that this echoing process slow down the logging process a lot, since it is currently implemented in a blocking mode, and flushes each row to the log file. This feature is therefore disabled by default, and not to be enabled on a production server, but only to make interactive debugging easier.

See http://blog.synopse.info/post/2013/02/0 … he-console

Offline

#2 2014-06-09 20:20:44

berndvf
Member
Registered: 2013-03-08
Posts: 16

Re: Logging to the console

I am trying to use EchoToConsole in a new application, but I am getting AVs no matter what events I log. I have also run the demos where services can be run as console and get the same result.

The AV occurs with the first call to TSynLog.Add.Log I call. When calling the LogHeaderLock in the LogInternal (line 40753), it then calls LogFileHeader which adds all the header information and then calls Flush (line 40596). This causes the AV on the line: inc(fTotalFileSize,fStream.Write(fTempBuf^,L)); because FStream is nil.

Offline

#3 2014-06-09 20:35:28

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: Logging to the console

Are you using the latest 1.18 nightly revision of the source code?

I just tried e.g. Sample 14, which by default do output all log to the console.
No AV.

Offline

#4 2014-06-30 19:26:45

berndvf
Member
Registered: 2013-03-08
Posts: 16

Re: Logging to the console

Looking at Sample 14 and your example above I see it is using TSQLLog.Family.EchoToConsole whereas I was using TSynLog.Family.EchoToConsole which gives the AV. Should I be using TSQLLog.Family and TSQLLog.Add rather the TSynLog by default ?

Offline

#5 2014-06-30 19:58:29

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: Logging to the console

TSynLog and TSQLLog are rather the same classes, with the exception of TObject serialization for TSQLLog.

Neither should give an AV.

Offline

Board footer

Powered by FluxBB