import org.apache.log4j.Logger; public class LoggerExample { private static Logger logger = Logger.getLogger(LoggerExample.class); public static void main(String[] args) { logger.info("Info message"); logger.error("Error message"); logger.removeAllAppenders(); logger.info("Info message after removing all appenders"); logger.error("Error message after removing all appenders"); } }In the above example, we have created an instance of the logger and used it to log messages at different levels. After logging the messages, we have used the removeAllAppenders method to remove all the registered appenders from the logger. This method belongs to the org.apache.log4j package library.