You are not logged in.
Pages: 1
sorry but I do not understand why does not work the log, I mean the file is created but nothing is written. I do not understand why.
....create a server
self.CreateMissingTables(0);
Server := TSQLHttpServer.Create(ServerPort,[self]);//,ServerName);
self.OnUpdateEvent := OnDatabaseUpdateEvent;
with TSQLLog.Family do begin
Level := LOG_VERBOSE;
AutoFlushTimeOut := 2;
DestinationPath := GetTempDir;
OnArchive := EventArchiveSynLZ;
ArchiveAfterDays := 1; // archive after one day
end;
TSQLLog.Add.Log(sllInfo,'test corchi');
Offline
I noticed that the log is sometimes written only after I closed the console application. Why?
Offline
sorry I read your example of the log but I was not yet clear to me, perhaps because it does not work! please you can write three lines of code that will allow me to create a log file. thanks
Offline
well I found the problem, I am running an application with the directive {$ APPTYPE CONSOLE}
and with the command readln go out the application.
I saw that as long as the program is started, the log does not write anything to the file which will be written only after readln
Offline
now I understand, I have to use TSQLlog.Family.SynLog.Flush (true) if I want the log to be written to the file before reaching the 4 kb, right?
Offline
Or you can set the AutoFlushTimeOut property to a auto-flush time period (in seconds).
Flushing the content at every row is just very slow (due to Windows API).
If there is an exception, flush is always done (for safety).
Offline
ok I will use flush sparingly, however AutoFlushTimeOut = 2 + with Appconsole readln; does not work, or rather writes only when they exceed the 4 kb and my Appconsole when part does not exceed 4 kb immediately because I septum in the following way
constructor TFileServer.Create(const ServerName,ServerPort: AnsiString;const aFilename: AnsiString);
var
inherited Create(CreateFileLicenseModel(true),aFilename,true);
self.CreateMissingTables(0);
Server := TSQLHttpServer.Create(ServerPort,[self]);
with QvLog.Family do begin
Level := [sllError,sllInfo,sllDebug,sllServiceCall]; //LOG_VERBOSE;//
AutoFlushTimeOut := 2;
DestinationPath := GetTempDir;
OnArchive := EventArchiveSynLZ;
//OnArchive := EventArchiveZip;
ArchiveAfterDays := 1; // archive after one day
// IncludeComputerNameInFileName:=true;
end;
QvLog.Add.Log(sllInfo,format('Database Name: %s',[ExpandFileName(aFilename)]));
QvLog.Add.Log(sllInfo,format('Server Port: %d',[strtoint(ServerPort)]));
QvLog.Add.Log(sllInfo,format('Server Name: %s',[ServerName]));
{$ifNdef SERVICE}
writeln('Server is Started');
{$ENDIF}
QvLog.Add.Log(sllInfo, 'Server is Started');
except
on E: Exception do
begin
QvLog.Add.Log(sllError,'Error launching the server' +#10+E.Message);
// handle initialization error here
end;
end;
QvLog.Family.SynLog.Flush(true);
end;
and if I read the file.log want to find written:
20121212 16310611 info Server Port: 8001
20121212 16310611 info Server Name: localhost
20121212 16310611 info Server is Started
and not wait until the file reaches the size of 4kb, if I wait more than 2 seconds (as set above -> AutoFlushTimeOut := 2;) does not write anything
Offline
Pages: 1