Friday, September 5, 2025
HomeLanguagesJavaLogManager checkAccess() method in Java with Examples

LogManager checkAccess() method in Java with Examples

The checkAccess() method of java.util.logging.LogManager is used to check if this context has the permissions to modify the logging configuration, which requires LoggingPermission(“control”). This method throws SecurityException if the exception condition occurs, as given below

Syntax:

public void checkAccess()
  throws SecurityException

Parameters: This method does not accepts any parameter.

Return Value: This method does not return anything. It just checks if this context has the permissions to modify 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 checkAccess() method:




// Java program to illustrate
// LogManager checkAccess() 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(
                "Checking for permissions\n");
  
            // Checking for permissions
            // using checkAccess() method
            logManager.checkAccess();
        }
        catch (SecurityException e) {
            System.out.println("Permission Denied");
        }
    }
}


Output:

LogManager: java.util.logging.LogManager@1540e19d
Checking for permissions

Permission Denied

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

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11863 POSTS0 COMMENTS
Shaida Kate Naidoo
6750 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6701 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS