Wednesday, July 3, 2024
HomeLanguagesJavaLogManager reset() method in Java with Examples

LogManager reset() method in Java with Examples

The reset() method of java.util.logging.LogManager is used to reset the logging configuration. This method throws SecurityException if the exception condition occurs, as given below

Syntax:

public void reset() throws SecurityException

Parameters: This method does not accepts any parameter.

Return Value: This method does not return anything. It just resets the logging configuration.

Exceptions: This method throws following exceptions:

  • SecurityException: if a security manager exists while the caller does not have logging permissions.

Below programs illustrate reset() method:




// Java program to illustrate
// LogManager reset() method
  
import java.util.logging.*;
import java.util.*;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        try {
            // Create LogManager object
            LogManager logManager
                = LogManager.getLogManager();
  
            System.out.println("LogManager: "
                               + logManager);
  
            System.out.println("Resetting the logging configuration");
  
            // Resetting the logging configuration
            // using reset() method
            logManager.reset();
        }
        catch (Exception e) {
            System.out.println(e);
        }
    }
}


Output:

LogManager: java.util.logging.LogManager@1540e19d
Resetting the logging configuration
java.security.AccessControlException:
 access denied ("java.util.logging.LoggingPermission" "control")

Reference: https://docs.oracle.com/javase/9/docs/api/java/util/logging/LogManager.html#reset–

Nokonwaba Nkukhwana
Experience as a skilled Java developer and proven expertise in using tools and technical developments to drive improvements throughout a entire software development life cycle. I have extensive industry and full life cycle experience in a java based environment, along with exceptional analytical, design and problem solving capabilities combined with excellent communication skills and ability to work alongside teams to define and refine new functionality. Currently working in springboot projects(microservices). Considering the fact that change is good, I am always keen to new challenges and growth to sharpen my skills.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments