program CustomLoggerSample; {$APPTYPE CONSOLE} uses System.SysUtils, MVCFramework.Logger, Winapi.Windows, Winapi.ShellAPI, Web.WebReq, Web.WebBroker, IdHTTPWebBrokerBridge, MyControllerU in 'MyControllerU.pas', WebModuleU in 'WebModuleU.pas' {MyWebModule: TWebModule} , CustomLoggerConfigU in 'CustomLoggerConfigU.pas'; {$R *.res} procedure RunServer(APort: Integer); var LInputRecord: TInputRecord; LEvent: DWord; LHandle: THandle; LServer: TIdHTTPWebBrokerBridge; begin SetDefaultLogger(GetLogger); // setting the custom logger Writeln('** DMVCFramework Server **'); Writeln('WARNING! Run this program in debug and check the Delphi "Event" debug window to see the custom logs'); Writeln('WARNING! Also, the log file are generated in the custom path "MyFolder\MyLogs"'); Writeln(Format('Starting HTTP Server on port %d', [APort])); LServer := TIdHTTPWebBrokerBridge.Create(nil); try LServer.DefaultPort := APort; LServer.Active := True; ShellExecute(0, 'open', pChar('http://localhost:' + inttostr(APort)), nil, nil, SW_SHOWMAXIMIZED); Writeln('Press ESC to stop the server'); LHandle := GetStdHandle(STD_INPUT_HANDLE); while True do begin Win32Check(ReadConsoleInput(LHandle, LInputRecord, 1, LEvent)); if (LInputRecord.EventType = KEY_EVENT) and LInputRecord.Event.KeyEvent.bKeyDown and (LInputRecord.Event.KeyEvent.wVirtualKeyCode = VK_ESCAPE) then break; end; finally LServer.Free; end; end; begin ReportMemoryLeaksOnShutdown := True; try if WebRequestHandler <> nil then WebRequestHandler.WebModuleClass := WebModuleClass; WebRequestHandlerProc.MaxConnections := 1024; RunServer(8080); except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end.