Over a million developers have joined DZone.

Do not use Relative Path with LogBack

DZone's Guide to

Do not use Relative Path with LogBack

· Java Zone ·
Free Resource

Build vs Buy a Data Quality Solution: Which is Best for You? Gain insights on a hybrid approach. Download white paper now!

A little tip that can be useful and save a lot of time : Do not use relative path with LogBack. I wondered why this little LogBack configuration didn’t work :

<?xml version="1.0" encoding="UTF-8" ?>

<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">

<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">

<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">

<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>

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

No file were written. I searched over a long time and after that tested with an absolute path and it worked really well. But absolute path is not very good. But, you can use system properties in the configuration, so I used user.dir to make the thing work :


<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">

And this time, it works well !

Hope this will be useful to somebody.


From http://www.baptiste-wicht.com/2010/08/do-not-use-relative-path-with-logback

Build vs Buy a Data Quality Solution: Which is Best for You? Maintaining high quality data is essential for operational efficiency, meaningful analytics and good long-term customer relationships. But, when dealing with multiple sources of data, data quality becomes complex, so you need to know when you should build a custom data quality tools effort over canned solutions. Download our whitepaper for more insights into a hybrid approach.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}