
I have ran HarishMain application using the logback.xml included in the attachments. I am seeing all messages as expected. Could you please run the tests on your side and see if it works for you? Harish Krishnaswamy wrote:
Hi Ceki,
I am using the RollingFileAppender and the SMTPAppender. And actually I get the email but its just not going to the file which makes me believe that its just not getting flushed. I am listing the shutdown task and the logback config. I appreciate the help!
-- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch package ch.qos.logback.classic; import java.net.InetAddress; import java.net.UnknownHostException; import org.slf4j.LoggerFactory; public class HarishMain { public static void main(String[] args) throws InterruptedException { org.slf4j.Logger logger = LoggerFactory.getLogger(HarishMain.class); logger.info("Harish"); Thread.sleep(3000); Runtime runtime = Runtime.getRuntime(); runtime.addShutdownHook(new Thread(new HarishRunnable())); } static class HarishRunnable implements Runnable { org.slf4j.Logger _logger = LoggerFactory.getLogger(this.getClass()); public void run() { _logger.info("Importer shutting down..."); org.slf4j.Logger emailLogger = LoggerFactory.getLogger("email"); emailLogger.info("status"); String hostName = null; try { hostName = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { hostName = "Unknown host"; } emailLogger.error(System.getProperty("user.name") + " - " + hostName); _logger.info("Importer shutdown complete."); LoggerContext lCtx = (LoggerContext) LoggerFactory.getILoggerFactory(); lCtx.stop(); } } }