Now I&#39;m trying this, but I&#39;m getting a NullPointerException on the first start()<br><br>        LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();<br>        lc.reset();<br>        <br>        //Setup Time Based File Naming and Triggering Policy<br>
        SizeAndTimeBasedFNATP&lt;ILoggingEvent&gt; timeBasedTriggering = new SizeAndTimeBasedFNATP&lt;ILoggingEvent&gt;();<br>        timeBasedTriggering.setContext(lc);<br>        timeBasedTriggering.setMaxFileSize(&quot;500MB&quot;);<br>
        <br>        //Setup Time Based Rolling Policy<br>        TimeBasedRollingPolicy&lt;ILoggingEvent&gt; rollingPolicy = new TimeBasedRollingPolicy&lt;ILoggingEvent&gt;();<br>        rollingPolicy.setContext(lc);<br>        rollingPolicy.setFileNamePattern(&quot;bidderserver-%d{yyyy-MM-dd-HH:mm:ss}-&quot;+hostname+&quot;-ip.%i.log&quot;);<br>
        rollingPolicy.setTimeBasedFileNamingAndTriggeringPolicy(timeBasedTriggering);<br><br>        //Set the rolling policy as a parent to the triggering policy<br>        timeBasedTriggering.setTimeBasedRollingPolicy(rollingPolicy);<br>
        <br>        //Set up a Pattern<br>        PatternLayout layout = new PatternLayout();<br>        layout.setPattern(&quot;%d{yyyy-MM-dd HH:mm:ss},%t %m%n&quot;);<br>        <br>        //Set up the Appender<br>        RollingFileAppender&lt;ILoggingEvent&gt; rollingFileAppender = new RollingFileAppender&lt;ILoggingEvent&gt;();<br>
        rollingFileAppender.setContext(lc);<br>        rollingFileAppender.setAppend(true);<br>        rollingFileAppender.setBufferedIO(true);<br>        rollingFileAppender.setBufferSize(16000000);<br>        rollingFileAppender.setPrudent(false);<br>
        rollingFileAppender.setImmediateFlush(false);<br>        rollingFileAppender.setLayout(layout);<br>        <br>        //Start!<br>        timeBasedTriggering.start();<br>        rollingPolicy.start();<br>        layout.start();<br>
        rollingFileAppender.start();<br><br><div class="gmail_quote">On Wed, Sep 9, 2009 at 11:17 AM, Nitro Star <span dir="ltr">&lt;<a href="mailto:nitrostar1@gmail.com">nitrostar1@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi!<br><br>I have been playing with logback for a couple of days and find a lot of its functionality amazing! I have a couple of questions that I was wondering if I could address!<br><br>I&#39;m using logback to log information about a java server that I&#39;m setting up. I want my log files to change every half hour and to never exceed 500MB. I would also like the logging system to cache 16MB of data before flushing to disk! Finally, I want the fileNamePattern to depend on the hostname where I&#39;m running the server!<br>

<br>So this are my questions:<br>a. I have found a way for the log files to change every hour, but not every half hour... Is there a way to do this? Is there a way I can define my own RollingPolicy?<br>b. Is there a way for me to define the fileNamePattern somewhere else other than in the logback.xml file?<br>

c. Is there a flush() function I can call when my server exists?<br><br>For b. I have tried something like:<br><br>LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();<br>        Logger logger = lc.getLogger(&quot;ROOT&quot;);<br>

        <br>        RollingFileAppender&lt;ILoggingEvent&gt; app = (RollingFileAppender&lt;ILoggingEvent&gt;)logger.getAppender(&quot;RootFileAppender&quot;);<br>        RollingPolicyBase rollingPolicy = (RollingPolicyBase)app.getRollingPolicy();<br>

        rollingPolicy.stop();<br>        rollingPolicy.setFileNamePattern(&quot;bidderserver-%d{yyyy-MM-dd-HH:mm:ss}-&quot;+hostname+&quot;-ip.%i.log&quot;);<br>        rollingPolicy.start();<br><br><br>But that doesn&#39;t seem to work :(<br>

<br>I&#39;m attaching my current logback.xml file.<br><br>Any and all help would be much appreciated!<br><br><br>Also, I tried visiting #<a href="http://qos.ch" target="_blank">qos.ch</a> in freenode, but there&#39;s noone there except me!<br>

<br>Thanks again,<br>Daniel<br>
</blockquote></div><br>