Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make externalFilesDir available as a property #181

Open
deje07 opened this issue Jul 5, 2018 · 2 comments
Open

Make externalFilesDir available as a property #181

deje07 opened this issue Jul 5, 2018 · 2 comments

Comments

@deje07
Copy link

deje07 commented Jul 5, 2018

The class AndroidContextUtil.java already contains a way to query the external files directory. This is actually the Context.getExternalFilesDir(null). The importance of this directory is than beginning with Android 7 this is a directory where the application can write without asking for permission, and this directory is also publicly readable, making it ideal for storing non-sensitive logfiles during development.
However there is no way to refer to this directory from the logback.xml file, because it is not registered in the logger context properties.

I suggest a new CoreConstants value like EXT_DATA_DIR which points to this directory, if available.

There are also more directories like the externalCacheDir which is also present in AndroidContextUtil but not registered in the logger context.

@wimdeblauwe
Copy link

FYI: If you need a workaround, you can use PropertyDefiner (See https://logback.qos.ch/manual/configuration.html#definingPropsOnTheFly). I used it to to expose BuildConfig variables to the XML configuration.

@voghDev
Copy link

voghDev commented May 25, 2020

Hi @wimdeblauwe , could PropertyDefiner be used to add a build.gradle property to the logback.xml file?
Example:

build.gradle

def MY_CUSTOM_HOST = "http://an.example.url"
def MY_CUSTOM_PORT = 1234

logback.xml

<configuration>
    ...

    <appender name="syslog-tls" class="com.papertrailapp.logback.Syslog4jAppender">
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>...</pattern>
        </layout>

        <syslogConfig class="org.productivity.java.syslog4j.impl.net.tcp.ssl.SSLTCPNetSyslogConfig">
            <host>${MY_CUSTOM_HOST}</host>
            <port>${MY_CUSTOM_PORT}</port>
            <sendLocalName>...</sendLocalName>
            <sendLocalTimestamp>...</sendLocalTimestamp>
            <maxMessageLength>...</maxMessageLength>
        </syslogConfig>
    </appender>
    
    ...
</configuration>

In case it can, could you post any example code, link, or public gist that I can check?
Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📋 Backlog
Development

No branches or pull requests

4 participants