I cannot read nlog.config file in asset folder of android platform
NLog.LogManager.Configuration = new XmlLoggingConfiguration("NLog.config");
How to read nlog file and also this file is in android asset.
I cannot read nlog.config file in asset folder of android platform
NLog.LogManager.Configuration = new XmlLoggingConfiguration("NLog.config");
How to read nlog file and also this file is in android asset.
Thanks for your response. I resolved this issue by setting autoReload="false" throwExceptions="false". Due to these two my config file was not visible. I dont know how they affect the file visibility but setting above two to false i can get config file now Thanks,
For Xamarin Android "NLog.config" (in this casing) in the assets folder will be loaded automatically. If the file name is different, then use:
You can also make use of Xamarin resource. Put the NLog.config file into the library project, then edit file's properties - change the build action to embedded resource.
See also: https://github.com/NLog/NLog/wiki/Explicit-NLog-configuration-loading#loading-nlog-configuration-from-xamarin-resource
you could also try to use this (nlog.config file with a Build Action as an AndroidAsset):
refer to: https://github.com/NLog/NLog/blob/master/src/NLog/Config/LoggingConfigurationFileLoader.cs#L101-L120
You can add an extension method to your context class that gets you the required asset as a stream:
And then in your activity context access it like:
Note that this will return a System.IO.Stream.
Good luck
Revert in case of queries.