How to Get Started with QuickLogger: A Comprehensive Guide

Nov 4, 2021 | Programming

Logging is an essential part of application development, allowing developers to track the flow of execution, capture errors, and gather performance metrics. With QuickLogger, a robust Delphi and Freepascal library, you can easily implement multi-provider logging that supports various outputs such as email, console, files, and more! In this blog, we’ll walk you through the installation, configuration, and usage of QuickLogger, ensuring your logging needs are met effortlessly.

Installation

To start using QuickLogger, follow these simple steps based on your preferred installation method:

From Package Managers

  • Search for QuickLogger in Delphinus or GetIt package managers.
  • Click Install to add it to your project.

From GitHub

  • Clone the QuickLogger GitHub repository or download the zip file and extract it.
  • Add the QuickLogger folder to your library path in the Delphi IDE.
  • Also, clone the QuickLib GitHub repository from here or download and extract the zip file.
  • Add the QuickLib folder to your library path in the Delphi IDE.

Basic Configuration and Usage

Once you have QuickLogger installed, configuring it is straightforward. Here’s a simple example that uses file and console providers:


uses 
    Quick.Logger, 
    Quick.Logger.Provider.Files, 
    Quick.Logger.Provider.Console;

begin
    // Adding Log File and console providers
    Logger.Providers.Add(GlobalLogFileProvider);
    Logger.Providers.Add(GlobalLogConsoleProvider);
    
    // Configure provider options
    with GlobalLogFileProvider do 
    begin
        FileName := 'Logger.log';
        DailyRotate := True;
        MaxFileSizeInMB := 20;
        LogLevel := LOG_ALL;
        Enabled := True;
    end;
    
    with GlobalLogConsoleProvider do 
    begin
        LogLevel := LOG_DEBUG;
        ShowEventColors := True;
        Enabled := True;
    end;

    Log('Test entry', etInfo);
    Log('Test number: %d', [1], etWarning);
end.

Let’s break this down with an analogy:

Think of QuickLogger as a traffic manager in a city. The logger is like the city’s traffic control center responsible for monitoring different routes (providers). In the example above:

  • The File Provider is akin to a camera capturing footage of traffic on the highway, allowing you to review it later.
  • The Console Provider acts as a live traffic report that updates instantly on a screen, helping you to see what’s happening in real-time.
  • You configure each “camera” to record at specific intervals (FileSize, Daily Rotate) and choose which events are critical to capture (Log Level).

Event Types and Customization

QuickLogger supports various event types to classify log messages, such as:

  • etInfo
  • etWarning
  • etError
  • etDebug
  • etCritical

You can customize how logs are recorded based on the event type and control the outputs for better analysis.

Troubleshooting

If you encounter any issues while using QuickLogger, here are some suggestions:

  • Ensure that all paths for log files are correct and writable.
  • Verify your log level settings; make sure they align with the events you wish to capture.
  • For help regarding integration and specific issues, don’t hesitate to seek support via forums or communities.
  • For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

QuickLogger is a versatile logging library that simplifies the process of capturing application events across multiple providers. With slow and steady integration into your application, you’ll find the log information invaluable for debugging and monitoring your applications.

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox