NLog: UnauthorizedAccessException when trying to create a simple FileTarget on Android
Type (choose one):
- Bug
NLog version: 4.3.10
Platform: Xamarin Android (tested on device running Nougat, works on emulator running Marshmallow)
Current NLog config (xml or C#, if relevant)
NLog.Config.LoggingConfiguration config = new NLog.Config.LoggingConfiguration();
NLog.Targets.FileTarget f = new NLog.Targets.FileTarget("f");
In case of a BUG:
- What is the current result?
System.UnauthorizedAccessException
Access to the path "/" is denied.
at System.IO.Directory.GetFileSystemEntries (System.String path, System.String searchPattern, System.IO.FileAttributes mask, System.IO.FileAttributes attrs) [0x00050] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/corlib/System.IO/Directory.cs:496
at System.IO.Directory.GetFiles (System.String path, System.String searchPattern) [0x00000] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/corlib/System.IO/Directory.cs:296
at NLog.Config.ConfigurationItemFactory.BuildDefaultFactory () [0x00084] in <dbf750d0ee3b4193a151c4e9f00bd425>:0
at NLog.Config.ConfigurationItemFactory.get_Default () [0x00007] in <dbf750d0ee3b4193a151c4e9f00bd425>:0
at NLog.Layouts.Layout.FromString (System.String layoutText) [0x00000] in <dbf750d0ee3b4193a151c4e9f00bd425>:0
at NLog.Layouts.Layout.op_Implicit (System.String text) [0x00000] in <dbf750d0ee3b4193a151c4e9f00bd425>:0
at NLog.Targets.TargetWithLayout..ctor () [0x00006] in <dbf750d0ee3b4193a151c4e9f00bd425>:0
at NLog.Targets.TargetWithLayoutHeaderAndFooter..ctor () [0x00000] in <dbf750d0ee3b4193a151c4e9f00bd425>:0
at NLog.Targets.FileTarget..ctor () [0x00016] in <dbf750d0ee3b4193a151c4e9f00bd425>:0
at NLog.Targets.FileTarget..ctor (System.String name) [0x00000] in <dbf750d0ee3b4193a151c4e9f00bd425>:0
at Droid.MainActivity.ConfigureLogging () [0x00023] in
/Droid/MainActivity.cs:143
at Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00002]
/Droid/MainActivity.cs:77
at Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00011] in <27c17fe440cf491ba8255bcefade6e02>:0
at (wrapper dynamic-method) System.Object:b5e891a4-6415-4583-b917-ff0357faa071 (intptr,intptr,intptr)
- What is the expected result?
Not an exception
- Did you checked the Internal log?
Not possible
- Please post full exception details (message, stacktrace, inner exceptions)
See above
- Are there any work arrounds? yes/no
No
- Is there a version in which it did worked?
No
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 33 (22 by maintainers)
https://github.com/NLog/NLog/issues/1186 😉