1

I have configured a logback.xml file, which writes logs into a file (and logcat)

code snippet here:

<configuration>

    <property name="USER_HOME" value='_________'/>

    <appender name="LOG" class="ch.qos.logback.core.FileAppender">
    <!--append to file-->
        <file>
        ${USER_HOME}/myApp.log
    </file>
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

Because it is an Android app (using kotlin), I cannot hardcode the path, I need the app to find it/make it based on what device it is on (it should be specified in the value'____') and I need it to be accessable (not in the internal storage).

(I tested with a non existing path and it didn't create it.)

I did find a few suggestions (${catalina.home} or ${user.home} etc. - none of them is working or I am using it wrong.)

I did read the manual but couldn't find any help.

I appologize if it is too trivial, but I cannot find the answer anywhere and have found few similar unanswered questions so I am trying to ask if anybody knows.

Thank you in advance.

(I will keep researching in the mean time)

Sophie M
  • 351
  • 5
  • 14

1 Answers1

1

If anyone ever had the same problem. this worked for the logback.xml

  <!-- save to context I found in the activity -->
    <property name="EXT_FILES_DIR" value="${EXT_DIR}/Android/data/${PACKAGE_NAME}/files"/>

However it only works if the path is inicialized in the main activity like this:

applicationContext.getExternalFilesDir(null)

It cannot create the file on it's own but in combination it can find it and save to it

Sophie M
  • 351
  • 5
  • 14