Using QuickLogger in a multi threaded windows service.
AdriaanBoshoff opened this issue · 3 comments
I'm running a windows service with dynamically created custom thread objects. When in the debug build the logging works as expected by outputting to the a debug console however when the service is running as normal however only the header seems to get added to the log file and nothing else. The header essentially is the only thing that gets added into the same log file over and over.
Is there a way I should be running the logger in the a multi threaded windows service?
Logger settings in the dpr:
{$IFDEF DEBUG}
try
// Setup Quick Logger
Logger.Providers.Add(GlobalLogConsoleProvider);
with GlobalLogConsoleProvider do
begin
LogLevel := LOG_DEBUG;
ShowEventColors := True;
Enabled := True;
end;
// In debug mode the service acts as a console application.
Log('TeraokaCheckWeigher DEBUG mode. Press enter to exit.', etInfo);
TeraokaCheckWeigher := TTeraokaCheckWeigher.Create(nil);
var
dummy: Boolean;
TeraokaCheckWeigher.ServiceStart(TeraokaCheckWeigher, dummy);
ReadLn;
// On exit, destroy the service object.
FreeAndNil(TeraokaCheckWeigher);
except
on E: Exception do
begin
Log(E.ClassName + ': ' + E.Message, etException);
Log('Press enter to exit.', etInfo);
ReadLn;
end;
end;
{$ELSE}
// Setup Quick Logger
Logger.Providers.Add(GlobalLogFileProvider);
with GlobalLogFileProvider do
begin
FileName := '.\Logger.log';
DailyRotate := False;
MaxFileSizeInMB := 20;
LogLevel := LOG_DEBUG;
Enabled := True;
end;
if not Application.DelayInitialize or Application.Installing then
Application.Initialize;
Application.CreateForm(TTeraokaCheckWeigher, TeraokaCheckWeigher);
Application.Run;
{$ENDIF}
Please, provide an absolute path for log file and try again.
Unfortunately this did not change anything. I still get header output only. I'll make a test service for you when I have some spare time. Just to add each thread is running a telnet client with threaded events = true otherwise the OnDataAvailable event doesnt get fired in the telnet client.
Seems to be a issue with using the GlobalLogFileProvider.