Overview of EGL Logging for Java Application

Logging plays a critical role in modern application development, providing a reliable way to capture important events, errors, and informational messages during runtime. It offers developers valuable insights into application behavior, aiding in performance monitoring, issue diagnosis, and understanding execution flow. Whether in development or production, effective logging enhances system reliability, streamlines troubleshooting, and supports long-term maintenance and audit requirements.

EGL Java runtime projects now support integration with SLF4J (Simple Logging Facade for Java), allowing seamless compatibility with popular logging frameworks such as Logback, Reload4j, and more. This integration enables developers to log messages using standard levels ERROR, WARN, INFO, DEBUG, and TRACE while providing the flexibility to configure log levels and output destinations (e.g., console, files) through external configuration files.

Below is a step-by-step example demonstrating how to integrate and use a logging framework specifically Logback within an EGL Java project using SLF4J.

Logging with Logback:

  1. Create an EGL Java Project.
  2. Download the required SLF4J-compatible Logback JARs from a trusted Maven repository. Required JARs typically include:
    • logback-classic.jar
    • logback-core.jar
  3. Add Logback JARs to the Classpath as follows:
    1. Right-click your project and select Java Build Path.
    2. Go to the Libraries tab, in the Java build path window
    3. Add the logback JARs using the Add External JARs option.
    4. Click Apply and Close.
  4. Create a Logback Configuration File (logback.xml) in “/JavaSource”.
  5. Create an EGL program and use the logging utility (loglib).
  6. Run the Java Application as follows:
    1. Right-click your project.
    2. Select Run As➔Java Application.
  7. Logs will appear in the console or in a log file, as configured in logback.xml.
Note:
  • If no SLF4J-compatible logging framework is detected, the system defaults to using java.util.logging (JUL).
  • Ensure that you include the necessary JARs and configuration files for any custom logging framework you plan to use.