You are not logged in.
Pages: 1
For save time, Just show my codes:
type
TMyLog = class(TSynLog)
end;
begin
with TMyLog.Family do begin
Level := LOG_VERBOSE;
DestinationPath := ExtractFilePath(ParamStr(0)) + 'logs';
end;
TMyLog.Add.Log(sllInfo, 'do some stuff');
end.
I have read the sample one by one, and see that per-class knowledge, but the codes above can't work: the log file created in dir of exe, not the logs dir, the string "do some stuff" not in log file, what happends? My SynCommons is the latest version, I can ensure that.
Offline
I suppose you had to include the trailing backslash to the 'logs\' value.
I've made a property setter to ensure it will be added if not specified.
See http://synopse.info/fossil/info/12b03d6a78
Thanks for the feedback.
Offline
I added '/' to the 'logs', then log file go into it, but still no my log info, and I open log file, the last line is
TMyLog 1.18.311 2014-10-08T01:05:15
Offline
I have try, like the same.
Offline
FYI, it works for me when I tried it (I have not committed the latest patch so I still manually added the trailing slash).
with TMyLog.Family do
begin
Level := [sllInfo, sllError, sllServer];
DestinationPath := ExtractFilePath(Application.ExeName) + 'logs\';
end;
TMyLog.Add.Log(sllInfo, 'Testing');
Question for @win2014: Does the logs folder exist?
Offline
FYI, it works for me when I tried it (I have not committed the latest patch so I still manually added the trailing slash).
with TMyLog.Family do begin Level := [sllInfo, sllError, sllServer]; DestinationPath := ExtractFilePath(Application.ExeName) + 'logs\'; end; TMyLog.Add.Log(sllInfo, 'Testing');
Question for @win2014: Does the logs folder exist?
Of course, I saw it. My mean is log info is not correct.
Offline
I just know that TSynLog can't work reason in my testing project.
My testing project is a console project, and I add 'Readln' procedure at the end, yes, when I add it, my logs lose, when I remove it, my logs are correct!
@ab, is this a bug? Could you check it?
Last edited by win2014 (2014-10-13 03:09:32)
Offline
I just right your .dpr, and here is what is written when you execute the program:
..... header ...
20141013 10403644 info do some stuff
So sounds right to me, right?
But you may be reading the file in debug mode.
In this case, the log content may still be in memory, not already flushed to the disk.
By default, and for a huge performance boost, data is written in a memory buffer, then written to the disk using a background thread.
If you add a "readln" after the "Add.Log" you would see all data appear in the file after a small delay.
See TSynLogFamily.BufferSize and TSynLog.Flush method or set TSynLogFamily.AutoFlushTimeOut and the corresponding documentation.
Offline
Also, note that AutoFlushTimeOut does not work when you are in Debug mode (DebugHook = 1).
Offline
I just right your .dpr, and here is what is written when you execute the program:
..... header ... 20141013 10403644 info do some stuff
So sounds right to me, right?
But you may be reading the file in debug mode.
In this case, the log content may still be in memory, not already flushed to the disk.
By default, and for a huge performance boost, data is written in a memory buffer, then written to the disk using a background thread.
If you add a "readln" after the "Add.Log" you would see all data appear in the file after a small delay.See TSynLogFamily.BufferSize and TSynLog.Flush method or set TSynLogFamily.AutoFlushTimeOut and the corresponding documentation.
Ok, I add AutoFlushTimeOut := 1; then the log string appear.
Thanks.
Offline
Pages: 1