DEV Community

leo
leo

Posted on

openGauss JDBC driver supports log management

log management
The openGauss JDBC driver supports the use of logging to help troubleshoot issues when using the openGauss JDBC driver in applications. openGauss JDBC supports the following three log management methods:

  1. The SLF4J log framework used by docking applications.
  2. The JdkLogger logging framework used by the docking application. SLF4J and JdkLogger are the mainstream frameworks for Java application log management in the industry. It is beyond the scope of this article to describe how applications use these frameworks. Users should refer to the corresponding official documents (SLF4J: http://www.slf4j.org/manual.html, JdkLogger: https://docs.oracle.com/javase/8/docs/technotes/guides/logging/overview.html).

Method 1: Connect to the SLF4J log framework of the application.

When establishing a connection, the url configures logger=Slf4JLogger.

SLF4J can be implemented using Log4j or Log4j2. When using Log4j to implement SLF4J, you need to add the following jar packages: log4j-.jar, slf4j-api-.jar, slf4j-log4*-.jar, ( differentiate versions), and configuration files: log4j.properties. If you use Log4j2 to implement SLF4J, you need to add the following jar packages: log4j-api-.jar, log4j-core-.jar, log4j-slf4j18-impl-.jar, slf4j-api--alpha1.jar (* distinguish version), and configuration file: log4j2.xml.

This method supports log control. SLF4J can implement powerful log management and control functions through related configurations in files, and it is recommended to use this method for log management.

Note: This method relies on the general API interface of slf4j, such as org.slf4j.LoggerFactory.getLogger(String name), org.slf4j.Logger.debug(String var1), org.slf4j.Logger.info(String var1), org. slf4j.Logger.warn(String warn), org.slf4j.Logger.warn(String warn), etc. If the above interface changes, the log will not be printed.

Method 2: Connect to the JdkLogger logging framework used by the application.

The default Java logging framework stores its configuration in a file named logging.properties. Java installs global configuration files in folders in the Java installation directory. logging.properties files can also be created and stored with individual projects.

Top comments (0)