I am trying to implemented logback-android, I have followed the same steps as described here in logback android
My code regarding that is
<configuration>
<!-- Create a file appender for a log in the application's data directory -->
<appender name="file" class="ch.qos.logback.core.RollingFileAppender">
<file>/sdcard/log/foo.log</file>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!-- Write INFO (and higher-level) messages to the log file -->
<root level="INFO">
<appender-ref ref="file" />
</root>
</configuration>
My code in activity is
public class MainActivity extends Activity {
static private final Logger LOG =
LoggerFactory.getLogger(MainActivity.class);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
BasicLogcatConfigurator.configureDefaultContext();
LOG.info("Hello Android!");
LOG.debug("reply: {}", Example.hello());
}
static class Example {
static private final Logger LOG =
LoggerFactory.getLogger(Example.class);
static public String hello() {
LOG.trace("entered hello()");
return "Hi there!";
}
}
}
I also using external storage permission in android manifest I am using emulator created a 10 mb sdcard folder. but when i run this code no file and folder is created inside that. Need help regarding where i am getting wrong Thanks
In my code it was a silly mistake ..
The xml file name should be exactly logback.xml
Due that the problem was coming and and the xml file was not loading. Now change the xml file name to logback.xml did the work for me