Updated on 2024-01-16 GMT+08:00

Configuring SDK Logging (SDK for Java)

OBS SDK for Java offers logging based on the open-source Apache Log4j 2 library. By default, the SDK stores WARN log files to the directory specified by the JDK system variable user.dir. You can modify the log configuration file based on your needs.

Procedure

  1. Obtain the file log4j2.xml from the OBS SDK for Java package.
  2. Modify the log level and storage path in the file as required.
  3. Save the file to the classpath root directory, or call Log4j2Configurator.setLogConfig to specify the storage path of the file.
  • For details about SDK logging, see Log Analysis (SDK for Java).
  • You can modify the log4j2.xml file to configure access permissions for log files.