-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xamarin UWP doesn't create a logfile #2632
Comments
Or NLog can't find the nlog.config, our you haven't correct access. Could you please test with a config made in c#? |
I have outsources the path to a variable and used it for fileName. That works for debug mode but I can't use it with .Net Native compilation. I've also tried it for internalLog but that didn't work: |
@MaxFe Instead of using NLog-variables for changing global parameters at runtime, then I recommend that you use GDC: https://github.com/NLog/NLog/wiki/Gdc-layout-renderer GDC parameters can be updated like this:
In the Regarding the internalLogFile, then you cannot use layout-renderers (To keep it simple and ensure it always works). I recommend you always configure the internalLogFile from code, and just have the internalLogLevel in the nlog.config.
Consider loading the NLog.config manually with an explicit path. If you are being recompiled to dotnet-native, then the new binaries might be a different place in release-mode and cannot find NLog.config.
|
It isn't working with release mode and C# approach. The error message say "System.PlatformNotSupportedException: 'Operation is not supported on this platform.'". -> I'm building for UWP. @snakefoot Thanks for the "GDC parameters" approach. I will try that out |
@MaxFe Do you have a callstack? Have you upgraded to NLog 4.5.0 RTM ? Have you made sure NOT to use |
I just updated to 4.5.1 (4h ago) and autoReload was set to true. The GDC Parameter isn't throwing an exception but it isn't working. I have tried autoReload with true and false and can't see the difference. The log does not get created. I still have the impression that .Net Native compilation is the problem. |
@MaxFe And the callstack for the PlatformNotSupportedException ? (Just call ToString() on the caught exception) |
When I tried the C# approach and got the "System.PlatformNotSupportedException" -> The Exception was thrown by the line var logfile = new NLog.Targets.FileTarget {
Name = "file",
Layout = "${date} | ${level} | ${message}",
FileName = logPath + "/qkiss_app-${shortdate}.log",
KeepFileOpen = false,
Encoding = Encoding.UTF8
}; All that works fine with debug mode. Why is that? |
That is the reason why I'm asking you to provide the stacktrace of the thrown PlatformNotSupportedException (For the third time). Again Just call ToString() on the caught exception. |
StackTrace for the C# approach: at System.Reflection.Runtime.Assemblies.RuntimeAssembly.get_CodeBase() in f:\dd\ndp\fxcore\CoreRT\src\System.Private.Reflection.Core\src\System\Reflection\Runtime\General\ThunkedApis.cs:line 63
at NLog.Config.ConfigurationItemFactory.GetAssemblyFileLocation(Assembly assembly)
at NLog.Config.ConfigurationItemFactory.BuildDefaultFactory()
at NLog.Config.ConfigurationItemFactory.get_Default()
at NLog.Layouts.Layout.FromString(String layoutText)
at NLog.Layouts.Layout.op_Implicit(String text)
at NLog.Targets.TargetWithLayout..ctor()
at NLog.Targets.TargetWithLayoutHeaderAndFooter..ctor()
at NLog.Targets.FileTarget..ctor()
at Projectname.Logger.NLogManager.InitLogger() in C:\<Project>\src\Projectname.Bootstrapper\Logger\NLogManager.cs:line 14
at Projectname.App.InitLogger() in C:\Project\src\Projectname\App.xaml.cs:line 64
at Projectname.App..ctor(IPlatformInitializer initializer) in C:\Project\src\Projectname\App.xaml.cs:line 30
at Project.App..ctor() in C:\<projectPath>\App.xaml.cs:line 26
at Project.UWP.MainPage..ctor() in C:\<projectPath>\ProjectName.UWP\MainPage.xaml.cs:line 20
at Project.UWP.Project_UWP_XamlTypeInfo.XamlTypeInfoProvider.Activate_4_MainPage() in C:\<projectPath>\ProjectName.UWP\obj\x86\Release\XamlTypeInfo.g.cs:line 293
at ProjectName.UWP.Projectname_UWP_XamlTypeInfo.Activator.Invoke()
at ProjectName.UWP.ProjectName_UWP_XamlTypeInfo.XamlUserType.ActivateInstance() in C:\<Project>\src\platform\ProjectName.UWP\obj\x86\Release\XamlTypeInfo.g.cs:line 713
at __Interop.Intrinsics.HasThisCall__47(Object __this, IntPtr pfn)
at __Interop.ReverseComStubs.Stub_19(Object __this, Void** unsafe_returnValue__retval, IntPtr __methodPtr) Source: System.Private.Reflection.Core |
You are for some reason not using the NetStandard1.3 DLL, which works with UWP. Please check the file-properties of the NLog.dll to ensure it is says: "NLog for NetStandard 1.3" Think you need to figure out why your build-process is choosing the wrong NLog.dll |
What operation system version is being used on the device ? Does it support UWP NetStandard2.0 ? |
It's Windows 10 Version 1709 (Build 16299.334) |
@MaxFe I see the problem now. Looks like this is not always supported: Will make a PR that fixes this. |
@MaxFe Can you check if the problem is resolved if you use this NLog-nuget-package: https://ci.appveyor.com/project/nlog/nlog/build/4.5.0-beta7399/artifacts Visual Studio allows you to setup a "Local Package Source", where you just point to folder on you local machine that contains the downloaded NLog-nuget-package. You probably have to clean your local nuget-cache before it will use the downloaded NLog-nuget-package (Visual Studio -> Tools -> Options -> Nuget -> Clear All Nuget Caches) |
@MaxFe Was able to get an UWP App running with NetStandard2.0. Discovered that callsite and GetCurrentClassLogger didn't like the new optimized Net Native. Have updated the PR with additional fixes. Please try this instead: https://ci.appveyor.com/project/nlog/nlog/build/4.5.0-beta7414/artifacts |
I've tried https://ci.appveyor.com/project/nlog/nlog/build/4.5.0-beta7414/artifacts and |
@MaxFe Excellent. I guess @304NotModified will include it in NLog ver. 4.5.2 unless I have broken some sacred rules in my PR #2643 |
Type (choose one):
NLog version: 4.5.0-rc07
Platform: .Net 4.7
Current NLog config
No log file gets created, even when I use the absolute path for my machine: C:/Users/<UserName>/AppData/Local/Packages/<PackageName>/LocalState/<filePrefix>-${shortdate}.log
What is the current result?
errors (Reflection etc.)
What is the expected result?
Did you checked the Internal log?
Please post full exception details (message, stacktrace, inner exceptions)
Are there any workarounds?
Is there a version in which it did work?
Environment:
The text was updated successfully, but these errors were encountered: