Write a log.txt file to save log

Hi,
I am working on some apps develop program, and I sometimes get error report from specific cellphone(maybe this time is samsung and next time might be Htc). That really annoyed me a lot.
So I was wondering if it’s possible for me to write a log.txt file in sdCard(on phones) or Desktop(pc).
I’ve done some research about this topic, but it seems not work for me.
I read this File I/O in Unity3D - PreviewLabs
and also http://www.thegameengineer.com/blog/2014/02/09/unity-11-logging/.

But I got error like “access to /…/ path is denied”. I think it’s permission issue, and have no idea how to fix that. Is there anyone can give me a hand with this? Thanks in advance.

If its for Android you need to add the permissions to the manifest. Also are you using Application.persistantDataPath?

1 Like

Hi,thanks for replying so soon. Do u mean that I need to create a xml file to get the permission? In fact, I tried. But have no idea how to use it? Can u give a little tutorial?

If you want the files to be written to the SDcard you need to go to the:
1.) player settings
2.) Android (icon should already be set since the target build is Android)
3.) Under “Other Settings” → Write Access
Set it from “Internal” to “External (SDCard)”

2 Likes

For android it is recommended to use Application.persistantDataPath not Application.dataPath just in case.

1 Like

Wow, thanks a lot!! That works just fine!!! thanks for teaching me…haha

1 Like

No problem glad I could help :slight_smile:

1 Like