How to do it...

We will start from the project created in the first recipe, take that project and clone it in your file system; this will be the starting point.

The goal is to write a log mechanism that does the following:

  • Writes all Log levels to file and through the SysLog protocol
  • Sends emails in case of error

Perform the following steps:

  1. First, we have to define a configuration file called LoggerProConfig.pas. In this file, we define the appenders, the log level, and we provide a log interface that's ready for use:
unit LoggerProConfig;interfaceuses  LoggerPro;const  LOG_TAG = 'PHONEBOOK_SERVER';function Log: ILogWriter;implementationuses  LoggerPro.FileAppender,  LoggerPro.EMailAppender,  LoggerPro.OutputDebugStringAppender, LoggerPro.UDPSyslogAppender, ...

Get Delphi Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.