Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set relative path for LogBack Appender

Is there a way to set a relative path for a Layout configuration in logback?

<configuration debug="true">
    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
        <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
            <layout class="ch.qos.logback.classic.html.HTMLLayout">
                <pattern>%relative%thread%mdc%level%logger%msg</pattern>
                <cssBuilder class="ch.qos.logback.classic.html.UrlCssBuilder">
            <url>http://localhost:8080/myProject/resources/css/main.css</url>
        </cssBuilder>
            </layout>
        </encoder>
        <file>F:/Projects/myProject/src/main/webapp/test.html</file>
    </appender>

    <root level="DEBUG">
        <appender-ref ref="FILE" />
    </root>
</configuration>

I would like to set the <file> to a relative path. Is there a way to put it into the webapp or WEB-INF folder? The same for the CSS

like image 436
user1601401 Avatar asked Mar 23 '26 15:03

user1601401


1 Answers

I saw this for Jetty (I did not try it myself):

<file>\${jetty.home}/logs/jetty.log</file>

and tried this for Tomcat 8 (which worked):

<file>${catalina.base}/logs/whatever.log</file>

You might find this helpful, but still need to craft the path under webapps manually...

like image 184
Veelkoov Avatar answered Mar 25 '26 04:03

Veelkoov