<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Ulrich,</div><div><br></div><div><blockquote type="cite">I thought logback would know the file it uses - why not supply the name?</blockquote></div><div><br></div><div>There could be no file (console) or a hundred files, so it's not possible to generalise.</div><div><br></div><div>Try something like this:</div><div><br></div><div><configuration><br>  <appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender"><br>    <file>mylog.txt</file><br>    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><br>      <!-- rollover daily --><br>      <fileNamePattern>mylog-%d{yyyy-MM-dd}.%i.txt</fileNamePattern><br>      <timeBasedFileNamingAndTriggeringPolicy<br>            class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><br>        <!-- or whenever the file size reaches 100MB --><br>        <maxFileSize>100MB</maxFileSize><br>      </timeBasedFileNamingAndTriggeringPolicy><br>    </rollingPolicy><br>    <encoder><br>      <pattern>%msg%n</pattern><br>    </encoder><br>  </appender><br><br><br>  <root level="DEBUG"><br>    <appender-ref ref="ROLLING" /><br>  </root><br><br></configuration></div><div><br></div><div>This example is directly from <a href="http://logback.qos.ch/manual/appenders.html">http://logback.qos.ch/manual/appenders.html</a></div><div><br></div><div>But instead SizeAndTimeBasedFNATP, you should subclass SizeAndTimeBasedFNATP and override the getActiveFileName() method. Then capture the filename, and put it into somewhere your app can see.</div><div><br></div><div>There might be other ways, but I think this approach would work.</div><div><br></div><div>David</div><div><br></div><div><br></div><br><div><div>On 31 Jul 2013, at 13:41, Ulrich <<a href="mailto:Forums@gombers.de">Forums@gombers.de</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Thank you. I don't want to set the filename or maintain the appender from my program. This is up to the operators running the application. And I don't want to add limitations beyond those given by logback itself. I thought logback would know the file it uses - why not supply the name?<br>I could also (and I do it already) set the logfile by the operationg system and provide the name as an argument. In this case the I must request that only the console-appender can be used. But I don't like this approach.<br><br>Ulrich<br><br><br>Am 31.07.2013 12:21, schrieb David Roussel:<br><blockquote type="cite">I've made my app know the logger file name so that I can put a link to it in an email.<br><br>Buy the way I did it was to make the app choose the filename and set a system property. Then in logback.xml refer to the system property.<br><br>If that approach does not work, because you are using a dynamic log file name, then I suggest you try subclassing the rolling appender and getting the new filename each time one is generated, and then putting that value into a static singleton that is visible to your app.<br><br>David<br><br>On 31 Jul 2013, at 11:12, Ulrich <<a href="mailto:Forums@gombers.de">Forums@gombers.de</a>> wrote:<br><br><blockquote type="cite"><br>Within my application I would like to know the filename used by it's logger. I've asked this question before but didn't get an answer. So I will give it another try.<br>I've browsed through the Javadoc of the classes and interfaces where I thought by their name they should be able to provide this piece of information (LoggerContext and Appender to name two of them), but wasn't lucky.<br><br>Can anyone help here?<br>Ulrich<br><br><br><br>_______________________________________________<br>Logback-user mailing list<br><a href="mailto:Logback-user@qos.ch">Logback-user@qos.ch</a><br>http://mailman.qos.ch/mailman/listinfo/logback-user<br></blockquote>_______________________________________________<br>Logback-user mailing list<br><a href="mailto:Logback-user@qos.ch">Logback-user@qos.ch</a><br>http://mailman.qos.ch/mailman/listinfo/logback-user<br><br></blockquote>_______________________________________________<br>Logback-user mailing list<br><a href="mailto:Logback-user@qos.ch">Logback-user@qos.ch</a><br>http://mailman.qos.ch/mailman/listinfo/logback-user<br></blockquote></div><br></body></html>