I want to use logback-android in Android project. Here is what I have done
I have copied the jar files in libs folder
and have logback.xml in assets folder
<configuration debug="true">
<property name="LOG_DIR" value="/mnt/sdcard/com.sf.quid/logs" />
<!-- Create a logcat appender -->
<appender name="LOG_CAT" class="ch.qos.logback.classic.android.LogcatAppender">
<encoder>
<pattern>%msg</pattern>
</encoder>
</appender>
<!-- Rolling Appender -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- File location -->
<file>${LOG_DIR}/quidpos.log</file>
<!-- Only log error messages to log file -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>DEBUG</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<!-- Rolling Policy -->
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>${LOG_DIR}/quidpos.%i.log</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>1</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>1MB</maxFileSize>
</triggeringPolicy>
<!-- Message encoder -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
<!-- Log level - change this to ERROR on release -->
<root level="debug">
<appender-ref ref="LOG_CAT"/>
<appender-ref ref="FILE" />
</root>
</configuration>
and here is dependencies section from build.gradle file
dependencies {
compile 'com.android.support:support-v4:19.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
I am using Android Studio 0.6.1 and Gradle 1.12(Android plugin 0.11.+), and when I try the Clean project, Run, etc options it results in the following error
Error:Execution failed for task ':multipos:mergeDebugResources'.
Unsupported type 'property' in file C:\Users\Jagmohan\AndroidStudioProjects\MultiPOS\multipos\src\main\res\assets\logback.xml
If anyone can identify the potential problem, please answer.
Thank you!
Your assets directory is in the wrong place. It should be src\main\assets
, not src\main\res\assets
.
It's trying to read your XML file as a resource file and is throwing an error since it's not a valid Android resource file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With