orhanobut / logger

✔️ Simple, pretty and powerful logger for android
Apache License 2.0
13.78k stars 2.14k forks source link

Where is the log file? #218

Closed tracer8 closed 5 years ago

tracer8 commented 5 years ago

I'm finding every where on readme and issue zone, but can't find save location of log file. I'm tried find on my phone too have no chance. Please tell me. :D

Edit: I'm use exact usage code: Logger.addLogAdapter(new DiskLogAdapter()); then Logger.d("debug");

weeld commented 5 years ago

Check your external memory, there should be the folder "logger" where all log files are located.

tracer8 commented 5 years ago

I find on my sdcard, my internal storage, nothing here. Tried on Android/Data/packageName still empty.

weeld commented 5 years ago

According to the code, the file is created when a message is saved on a disc: File logFile = getLogFile(folder, "logs"); ... newFile = new File(folder, String.format("%s_%s.csv", fileName, newFileCount));

When you build CsvFormatStrategy, "diskPath" and "folder" are defined: String diskPath = Environment.getExternalStorageDirectory().getAbsolutePath(); String folder = diskPath + File.separatorChar + "logger";

So, I guess, the location should be:

/logger/ Because getExternalStorageDirectory() returns the storage directory: **Return the primary shared/external storage directory. This directory may not currently be accessible if it has been mounted by the user on their computer, has been removed from the device, or some other problem has happened. You can determine its current state with getExternalStorageState(). Note: don't be confused by the word "external" here. This directory can better be thought as media/shared storage. It is a filesystem that can hold a relatively large amount of data and that is shared across all applications (does not enforce permissions). Traditionally this is an SD card, but it may also be implemented as built-in storage in a device that is distinct from the protected internal storage and can be mounted as a filesystem on a computer. On devices with multiple users (as described by UserManager), each user has their own isolated shared storage. Applications only have access to the shared storage for the user they're running as. In devices with multiple shared/external storage directories, this directory represents the primary storage that the user will interact with. Access to secondary storage is available through Context.getExternalFilesDirs(String), Context.getExternalCacheDirs(), and Context.getExternalMediaDirs(). Applications should not directly use this top-level directory, in order to avoid polluting the user's root namespace. Any files that are private to the application should be placed in a directory returned by Context.getExternalFilesDir, which the system will take care of deleting if the application is uninstalled. Other shared files should be placed in one of the directories returned by getExternalStoragePublicDirectory(String).**
tracer8 commented 5 years ago

Thanks for helping!