---
title: "How to generate Log file in Android Studio?"  
description: "How to generate Log file in Android Studio?"  
author: "Tarun Gautam"  
published: 2018-01-12  
updated: 2018-01-12  
canonical: https://answers.mindstick.com/qa/32937/how-to-generate-log-file-in-android-studio  
category: "technology"  
tags: ["android", "android studio", "log"]  
reading_time: 1 minute  

---

# How to generate Log file in Android Studio?

How to generate [Log file](https://www.mindstick.com/articles/327201/create-log-file-in-c-sharp) in [Android Studio](https://www.mindstick.com/blog/10942/android-studio-vs-eclipse)?

## Answers

### Answer by Prateek sharma

In order to generate the **log [file](https://www.mindstick.com/articles/59/encrypting-and-decrypting-files-using-c-sharp)**, you need to write the following code

1. You need to add the following static variable in your **MainActivity:**

```
private static final Logger logger = LoggerFactory.getLogger();
```

2. Edit the onCreate() method of the MainActivity:

```
PropertyConfigurator.getConfigurator(this).configure();
```

3. Create a file **microlog.properties** and store it in assets directory of your application

4. Now edit the microlog.properties file with the following code:

```
microlog.level=DEBUG
microlog.appender=LogCatAppender;FileAppender
microlog.formatter=PatternFormatter
microlog.formatter.PatternFormatter.pattern=%c [%P] %m %T
```

5. You can add logging statements like this-

```
logger.debug("M4A");
```

6. If you want to create the log file for each activity, you need to add a logger object as specified in 1 in each activity.

7. You need to add the following **permission**:

```
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
```

\

\


---

Original Source: https://answers.mindstick.com/qa/32937/how-to-generate-log-file-in-android-studio

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
