简体   繁体   中英

Java using multiple logger types in the same file skipping log statements

There is an maven OSGI component in which I have a call to EclipseStarter.stop() statement which shuts down the OSGI framework. There are a couple of log statements printed after this line. I have used pax-logging with log4j2 as the logging backend and JCL at the frontend.

Since OSGI framework is down the log messages do not print through pax-logging-log4j2. Therefore I am trying to use java util logging to print these messages. The logger initialization in the java file is done as follows.

private static final Log log = LogFactory.getLog(MyClass.class);
private static final Logger logger = Logger.getLogger(MyClass.class.getName());

log.info("Before shutdown");

EclipseStarter.stop();

logger.log(Level.INFO, "After shutdown JUL");    
log.info("After shutdown JCL");

The util logging statement seems to be skipping when I debugged.

In order to see output from a logger you have to attach a Handler subclass . You can add them from code or you can create a logging.properties .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM