Hi Ceki,<div><br></div><div>I am using the&nbsp;RollingFileAppender&nbsp;and the&nbsp;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!</div>
<div><br></div><div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&lt;configuration&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br>
</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp;&lt;appender name=&quot;FILE&quot; class=&quot;ch.qos.logback.core.rolling.RollingFileAppender&quot;&gt;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;file&gt;file.log&lt;/file&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br>
</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;rollingPolicy class=&quot;ch.qos.logback.core.rolling.TimeBasedRollingPolicy&quot;&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;FileNamePattern&gt;file-%d{yyyy-MM-dd}.log&lt;/FileNamePattern&gt;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;/rollingPolicy&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br>
</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;layout class=&quot;ch.qos.logback.classic.PatternLayout&quot;&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Pattern&gt;%date %level [%thread] [%logger{0}] %msg%n%ex&lt;/Pattern&gt;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;/layout&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp;&lt;/appender&gt;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br></span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp;&lt;appender name=&quot;STDOUT&quot; class=&quot;ch.qos.logback.core.ConsoleAppender&quot;&gt;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;layout class=&quot;ch.qos.logback.classic.PatternLayout&quot;&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Pattern&gt;%msg%n&lt;/Pattern&gt;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;/layout&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp;&lt;/appender&gt;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br></span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp;&lt;root&gt;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;level value=&quot;info&quot; /&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;appender-ref ref=&quot;FILE&quot; /&gt;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;!-- appender-ref ref=&quot;STDOUT&quot; /--&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp;&lt;/root&gt;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br></span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp;&lt;appender name=&quot;EMAIL&quot; class=&quot;ch.qos.logback.classic.net.SMTPAppender&quot;&gt;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;SMTPHost&gt;<a href="http://smtp.gmail.com">smtp.gmail.com</a>&lt;/SMTPHost&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;SMTPPort&gt;465&lt;/SMTPPort&gt;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;SSL&gt;true&lt;/SSL&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;Username&gt;<a href="mailto:user@gmail.com">user@gmail.com</a>&lt;/Username&gt;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;Password&gt;pwd&lt;/Password&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br>
</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;To&gt;<a href="mailto:id@domain.com">id@domain.com</a>&lt;/To&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;From&gt;<a href="mailto:name@gmail.com">name@gmail.com</a>&lt;/From&gt;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;Subject&gt;Stats - %m&lt;/Subject&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;layout class=&quot;ch.qos.logback.classic.PatternLayout&quot;&gt;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Pattern&gt;%msg%n&lt;/Pattern&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;/layout&gt;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp;&lt;/appender&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br></span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp;&lt;logger name=&quot;email&quot;&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;level value=&quot;info&quot; /&gt;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;appender-ref ref=&quot;EMAIL&quot; /&gt;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp;&lt;/logger&gt;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br></span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&lt;/configuration&gt;</span></div>
<div><br></div><br></div><div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return new Runnable()</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;public void run()</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; font-size: 12px;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// If another thread cleared this task then return</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (_shutdownTask == null)</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br>
</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_shutdownTask = null;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br>
</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_<a href="http://logger.info">logger.info</a>(&quot;Importer shutting down...&quot;);</span></div><div>
<span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br></span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; font-size: 12px; ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Log stats</span><br>
</div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (_piLoader != null)</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PiStats stats = _ctx.get(PiStats.class);</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br>
</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; font-size: 12px; ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Logger emailLogger = LoggerFactory.getLogger(&quot;email&quot;);</span><br></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;emailLogger.info(stats.toString());</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br></span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String hostName = null;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br></span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hostName = InetAddress.getLocalHost().getHostName();</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;catch (UnknownHostException e)</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hostName = &quot;Unknown host&quot;;</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br></span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// This will trigger the email</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// <a href="http://user.name">user.name</a> and host will indicate the environment this message is coming from</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;emailLogger.error(System.getProperty(&quot;<a href="http://user.name">user.name</a>&quot;) + &quot; - &quot; + hostName);</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br></span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Cleanup state</span></div><div><br></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// This will give any open SqlSessions a chance to finalize</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// System.runFinalization();</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br>
</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_runningToken.delete();</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br>
</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_<a href="http://logger.info">logger.info</a>(&quot;Importer shutdown complete.&quot;);</span></div><div>
<span class="Apple-style-span" style="font-family: &#39;courier new&#39;; font-size: 12px;"><br></span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><span class="Apple-style-span" style="font-size: small;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span></span><span class="Apple-style-span" style="white-space: pre; "><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace; "><span class="Apple-style-span" style="font-size: small; "><span class="Apple-style-span" style="text-decoration: none;">LoggerContext</span></span></span><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><span class="Apple-style-span" style="font-size: small;"> lCtx = (LoggerContext) LoggerFactory.getILoggerFactory();</span></span></span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; font-size: 12px; ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lCtx.stop();</span><br></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;};</span></div><div><br></div><div>-Harish</div></div><div><br><div class="gmail_quote">On Thu, Feb 5, 2009 at 2:57 PM, Ceki Gulcu <span dir="ltr">&lt;ceki@qos.ch&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
Hello Harish,<br>
<br>
What types of appenders are you using? Also, if some code shuts down logback before the &nbsp;shutdown hook gets executed, any code within the shutdown hook will be using closed appenders.<br>
<br>
The different behavior on Windows and SunOS is quite baffling though.<br>
<br>
HTH,<div><div></div><div class="Wj3C7c"><br>
<br>
Harish Krishnaswamy wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have a weird problem in my multi-threaded application on Solaris but not on Windows XP.<br>
<br>
Basically I have a bunch of tasks that are executed by the ThreadPoolExecutor and when the last task is executed the ThreadPoolExecutor is required to run a shutdown task (Runnable) provided to the executor by the main thread. The problem is, the log messages from this shutdown task never get flushed to the log file but it sure gets executed. I even added the LoggerContext.stop() to no effect. I am completely baffled as to why it is not flushing, any pointers/ideas will be much appreciated. Thanks.<br>

<br>
System Spec<br>
==========<br>
System = SunOS<br>
Node = jdcsj002<br>
Release = 5.10<br>
KernelID = Generic_137137-09<br>
Machine = sun4u<br>
<br>
-Harish<br>
<br>
</blockquote>
<br></div></div><font color="#888888">
-- <br>
Ceki Gülcü<br>
Logback: The reliable, generic, fast and flexible logging framework for Java.<br>
<a href="http://logback.qos.ch" target="_blank">http://logback.qos.ch</a><br>
_______________________________________________<br>
Logback-user mailing list<br>
Logback-user@qos.ch<br>
<a href="http://qos.ch/mailman/listinfo/logback-user" target="_blank">http://qos.ch/mailman/listinfo/logback-user</a><br>
</font></blockquote></div><br></div>