orhanobut / logger

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

how can i make the log file name as i want? #219

Open jerryzhj opened 5 years ago

jerryzhj commented 5 years ago

Please try to fill all questions below before submitting an issue.

jerryzhj commented 5 years ago

I need to make file name different. but I do not know how to change it.

lby1992 commented 5 years ago

@jerryzhj Take a look at com.orhanobut.logger.DiskLogStrategy.java, the line: 52 said that you can't change the file name if you're using DiskLogStrategy.java:

File logFile = getLogFile(folder, "logs");

If you want to change the file name your logs saved into, you can make a copy of DiskLogStrategy.java , use the name you want and set this as your log strategy.

aotian16 commented 4 years ago

I have same question, so I copy CsvFormatStrategy and DiskLogStrategy, custom them.

gist here

SunnyBoy-WYH commented 3 years ago

thx for all. I copy the DiskLogStrategy.java and addAdapter with it , then i custom it successfully. ` String diskPath = Environment.getExternalStorageDirectory().getAbsolutePath(); String folder = diskPath + File.separatorChar + "loggerR";

    HandlerThread ht = new HandlerThread("AndroidFileLogger." + folder);`