novotnyllc / metrolog Goto Github PK
View Code? Open in Web Editor NEWA lightweight logging system designed specifically for Windows Store and Windows Phone 8 apps.
License: MIT License
A lightweight logging system designed specifically for Windows Store and Windows Phone 8 apps.
License: MIT License
The NuGet package states that it's for "Windows Store" apps and WinJS. In a fresh WinJS app, I get the following when trying to install the NuGet package:
PM> Install-Package -Verbose MetroLog
Added file 'MetroLog ReadMe.txt' to folder 'MetroLog.0.8.1.1\content\win8-javascript'.
Added file 'MetroLog.WinRT.d.ts' to folder 'MetroLog.0.8.1.1\content\win8-javascript\typings'.
Added file 'winrt.d.ts' to folder 'MetroLog.0.8.1.1\content\win8-javascript\typings'.
Added file 'MetroLog.dll' to folder 'MetroLog.0.8.1.1\lib\net45'.
Added file 'MetroLog.NetFx.dll' to folder 'MetroLog.0.8.1.1\lib\net45'.
Added file 'MetroLog.dll' to folder 'MetroLog.0.8.1.1\lib\netcore45'.
Added file 'MetroLog.NetCore.dll' to folder 'MetroLog.0.8.1.1\lib\netcore45'.
Added file 'MetroLog.NetCore.pri' to folder 'MetroLog.0.8.1.1\lib\netcore45'.
Added file 'MetroLog.WinRT.pri' to folder 'MetroLog.0.8.1.1\lib\netcore45'.
Added file 'MetroLog.WinRT.winmd' to folder 'MetroLog.0.8.1.1\lib\netcore45'.
Added file 'MetroLog.dll' to folder 'MetroLog.0.8.1.1\lib\portable-net45+wp8+win8'.
Added file 'MetroLog.0.8.1.1.nuspec' to folder 'MetroLog.0.8.1.1'.
Added file 'MetroLog.0.8.1.1.nupkg' to folder 'MetroLog.0.8.1.1'.
Successfully installed 'MetroLog 0.8.1.1'.
Added file 'packages.config'.
Added file 'packages.config'.
Removed file 'MetroLog.WinRT.d.ts' to folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1\content\win8-javascript\typings'.
Removed file 'winrt.d.ts' to folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1\content\win8-javascript\typings'.
Removed folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1\content\win8-javascript\typings'.
Removed file 'MetroLog.dll' to folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1\lib\portable-net45+wp8+win8'.
Removed folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1\lib\portable-net45+wp8+win8'.
Removed file 'MetroLog ReadMe.txt' to folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1\content\win8-javascript'.
Removed folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1\content\win8-javascript'.
Removed file 'MetroLog.dll' to folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1\lib\netcore45'.
Removed file 'MetroLog.NetCore.dll' to folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1\lib\netcore45'.
Removed file 'MetroLog.NetCore.pri' to folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1\lib\netcore45'.
Removed file 'MetroLog.WinRT.pri' to folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1\lib\netcore45'.
Removed file 'MetroLog.WinRT.winmd' to folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1\lib\netcore45'.
Removed folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1\lib\netcore45'.
Removed file 'MetroLog.dll' to folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1\lib\net45'.
Removed file 'MetroLog.NetFx.dll' to folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1\lib\net45'.
Removed folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1\lib\net45'.
Removed folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1\content'.
Removed folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1\lib'.
Removed file 'MetroLog.0.8.1.1.nuspec' to folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1'.
Removed file 'MetroLog.0.8.1.1.nupkg' to folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1'.
Removed folder 'C:\KCI\Test\Mfs\packages\MetroLog.0.8.1.1'.
Successfully uninstalled 'MetroLog 0.8.1.1'.
Install failed. Rolling back...
Install-Package : Failed to add reference to 'MetroLog'.
At line:1 char:1
- CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
- FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
Really love the concept of MetroLog but it's unclear to me of how to get the logs. Specially for example the EventTracingForWindows (ETW). Would love to have a kind of logging our testers can read out of the apps without to much trouble. I can't choose the right option because I have trouble comparing the different log targets and how to get those out of the device.
Is it possible to support .NET 4.0 client profile?
(Currently 4.5 is a bit to high for me).
I understand that it doesn't work because it's compiled in Release, but it's really annoying... It could easily be fixed by adding #define DEBUG
in DebugTarget.cs
I want to change log level in coding after initializing, is there any method?
The GlobalCrashHandler class assumes you're using a XAML-based application, so I wanted to roll my own to handle the same situation for WinJS. Unfortunately, the LazyFlushManager is internal and so is the GetTargets method on the LoggingConfiguration.
So, I can't figure out how to make sure that all the messages are flushed before the app exits.
It would be nice to have a method like
LogManagerFactory.DefaultConfiguration.AllTargets
which would basically NLog's method for internal GetTargets; or perhaps event having that as public.
Reason: I would like to gracefully flush all logs at shutdown; so it makes sense to find all the targets from configuration and issuing flush command one at a time to ensure no multiple writing problems.
PS: For Mono, suggested profile to use is 158;
I've created a portable file target which uses PCLStorage And System.Net.Compression nuget packages. It allows creating files on all different plattforms with it.
Source is avilable here: http://pastebin.com/fUgBi8sk
(I created an issue because pull request didn't work and I did not found any contact details)
Portable libraries are supposed to have a NeutralResourcesLanguageAttribute on them so that resources from them can be loaded correctly when running in Windows Store apps. If they don't, the resources may not load correctly. Adding this attribute will also fix this warning when building:
8>C:\git\MetroLog\MetroLog\bin\Release\MetroLog.dll : warning MSB3817: The assembly "C:\git\MetroLog\MetroLog\bin\Release\MetroLog.dll" does not have a NeutralResourcesLanguageAttribute on it. To be used in an app package, portable libraries must define a NeutralResourcesLanguageAttribute on their main assembly (ie, the one containing code, not a satellite assembly).
I'm using MetroLog in my Windows 8.1 app via Nuget and it seems that the SqLite target is not available (due to a refactoring perhaps?). Will a package be provided in the future?
on this page https://github.com/mbrit/MetroLog/wiki/Configuration
would it be better for perf to have log as a static field?
Currently you need to initialize the logging system in your app's startup code by calling LogManagerFactory.Initialize(). It would be nicer if you only needed to do this if you wanted to customize the configuration. Then you'd just have to add the NuGet package and start using the logging APIs when you needed them.
The default configuration might vary by platform and include logging targets which are platform specific. The core portable library could probe for the platform-specific libraries by calling Assembly.Load on them, and if it successfully loads one of them calling into a platform-specific initialization method. The PCL Contrib project does something similar in the Source\Portable.Runtime\Adaptation folder (the code for MetroLog could probably be a lot simpler).
Works fine with VS 2012 Ultimate, but Express edition throws the following error:
The application which this project type is based on was not found. Please try this link for further information: http://go.microsoft.com/fwlink/?prd=12395&pver=11&sbp=ProjectTypeDeprecated&plcid=0x409&clcid=0x409&ar=MSDN&sar=ProjectCompatibility&o1=786C830F-07A1-408B-BD7F-6EE04809D6DB"
Can you please suggest workarounds?
Thanks.
I've noticed that the JsonPostTarget seems to fail in Windows Store apps (with the exception of the sample app) with the following stack trace:
3|2013-04-29T21:27:50.3932297+00:00|TRACE|3|Failed to flush for target 'MetroLog.Targets.JsonPostTarget'. --> System.InvalidOperationException: The API 'System.Exception.get_TargetSite()' cannot be used on the current platform. See http://go.microsoft.com/fwlink/?LinkId=248273 for more information.
at System.Reflection.Emit.DynamicILGenerator.GetTokenFor(RuntimeMethodInfo rtMeth)
at System.Reflection.Emit.DynamicILGenerator.Emit(OpCode opcode, MethodInfo meth)
at System.Linq.Expressions.Compiler.LambdaCompiler.EmitMethodCall(MethodInfo mi, IArgumentProvider args, Type objectType, CompilationFlags flags)
at System.Linq.Expressions.Compiler.LambdaCompiler.EmitMethodCallExpression(Expression expr, CompilationFlags flags)
at System.Linq.Expressions.Compiler.LambdaCompiler.EmitExpression(Expression node, CompilationFlags flags)
at System.Linq.Expressions.Compiler.LambdaCompiler.EmitUnary(UnaryExpression node, CompilationFlags flags)
at System.Linq.Expressions.Compiler.LambdaCompiler.EmitExpression(Expression node, CompilationFlags flags)
at System.Linq.Expressions.Compiler.LambdaCompiler.EmitLambdaBody(CompilerScope parent, Boolean inlined, CompilationFlags flags)
at System.Linq.Expressions.Expression`1.Compile()
at MetroLog.Internal.Reflection.ReflectionUtils.GetGetMethodByExpression(PropertyInfo propertyInfo)
at MetroLog.Internal.Reflection.ReflectionUtils.GetGetMethod(PropertyInfo propertyInfo)
at MetroLog.Internal.PocoJsonSerializerStrategy.GetterValueFactory(Type type)
at MetroLog.Internal.DataContractJsonSerializerStrategy.GetterValueFactory(Type type)
at MetroLog.Internal.Reflection.ReflectionUtils.ThreadSafeDictionary`2.AddValue(TKey key)
at MetroLog.Internal.Reflection.ReflectionUtils.ThreadSafeDictionary`2.Get(TKey key)
at MetroLog.Internal.Reflection.ReflectionUtils.ThreadSafeDictionary`2.get_Item(TKey key)
at MetroLog.Internal.PocoJsonSerializerStrategy.TrySerializeUnknownTypes(Object input, Object& output)
at MetroLog.Internal.PocoJsonSerializerStrategy.SerializeNonPrimitiveObject(Object input, Object& output)
at MetroLog.Internal.SimpleJson.SerializeValue(IJsonSerializerStrategy jsonSerializerStrategy, Object value, StringBuilder builder)
at MetroLog.Internal.SimpleJson.SerializeObject(IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable keys, IEnumerable values, StringBuilder builder)
at MetroLog.Internal.SimpleJson.SerializeValue(IJsonSerializerStrategy jsonSerializerStrategy, Object value, StringBuilder builder)
at MetroLog.Internal.SimpleJson.SerializeValue(IJsonSerializerStrategy jsonSerializerStrategy, Object value, StringBuilder builder)
at MetroLog.Internal.SimpleJson.SerializeArray(IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable anArray, StringBuilder builder)
at MetroLog.Internal.SimpleJson.SerializeValue(IJsonSerializerStrategy jsonSerializerStrategy, Object value, StringBuilder builder)
at MetroLog.Internal.SimpleJson.SerializeObject(IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable keys, IEnumerable values, StringBuilder builder)
at MetroLog.Internal.SimpleJson.SerializeValue(IJsonSerializerStrategy jsonSerializerStrategy, Object value, StringBuilder builder)
at MetroLog.Internal.SimpleJson.SerializeValue(IJsonSerializerStrategy jsonSerializerStrategy, Object value, StringBuilder builder)
at MetroLog.Internal.SimpleJson.SerializeObject(Object json, IJsonSerializerStrategy jsonSerializerStrategy)
at MetroLog.Internal.SimpleJson.SerializeObject(Object json)
at MetroLog.Targets.JsonPostWrapper.ToJson()
at MetroLog.Targets.JsonPostTarget.<DoFlushAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MetroLog.Targets.BufferedTarget.<FlushAsync>d__1.MoveNext()
This only fails when it's trying to serialise an exception, ie calls to Log.Error()
Given it works correctly in your sample project I had assumed it was an issue with the NuGet package, however when I try creating a Windows Store project inside the MetroLog solution with the following code, I see the same exception:
var jsonPostTarget = new JsonPostTarget(1, new Uri("http://someendpoint/"));
var settings = LogManagerFactory.CreateLibraryDefaultSettings();
settings.AddTarget(LogLevel.Trace, LogLevel.Fatal, jsonPostTarget);
var log = LogManagerFactory.CreateLogManager(settings).GetLogger<MainPage>();
try
{
throw new Exception("Error Message");
}
catch (Exception ex)
{
log.Error("Error", ex);
}
Any ideas?
Hi. Thank you for MetroLog! I like how it's so lightweight and simple.
I installed MetroLog on my WinRT app and I'm confused about some things. First, I've never used NLog and actually I'm pretty new to logging in general, but I'm trying to follow the readme and the sample to no avail, so I was left to guess with Intellisense and this is what I came up with. Please tell me if I'm doing it wrong.
sealed partial class App : ILoggable
.private readonly Logger _log;
_log = LogManager.GetLogger(this, LogManager.DefaultConfiguration);
UnhandledException += App_UnhandledException;
void App_UnhandledException(object sender, UnhandledException e) { _log.Fatal("Fatal exception.", e.Exception); }
public sealed partial class Home : ILoggable
_log.Info("Loading data...");
try ... catch (Exception ex) { _log.Fatal("Unable to do magic.", ex); }
What I don't understand is where to dump this data or what to do with it and at what point? Will you please offer some guidance. I'm looking for WinRT logging information online and I just can't find the answers I need.
You help is extremely appreciated. Thank you!
LoggingConfiguration.IsEnabled is set to false thus in default configuration logging will be disabled. I downloaded NuGet packages and took me a while to figure out why it doesn't work - finally found it after downloading code from GitHub. Sample app wasn't working either.
Currently you need to add this to enable logging:
LogManagerFactory.DefaultConfiguration.IsEnabled = true;
I think it should be enabled by default.
This is the wrong way round. It's the configuration that needs to be monitored and enlisted, not the individual loggers.
Metrolog is being called via a PCL from both a Xamarin.Android and Xamarin.iOS project. Each Xamarin project has the corresponding Metrolog.Platform project reference from nuget.
Calls from Xamarin.Android work without issues.
Unhandled managed exception: An exception was thrown by the type initializer for MetroLog.LogManagerFactory (System.TypeInitializationException)
Try to use in background task WP 8.1
Method 'LiveTileAgent.LiveTileBackgroundTask.Log.get()' returns 'MetroLog.ILogger', which is not a valid Windows Runtime type. Methods exposed to Windows Runtime must return only Windows Runtime types.
In the static constructor of the WinRT Logger class, it adds 4 Targets and there is no way to change it from the outside.
We should be allowed to modify these settings
The MetroLog.NetCore.Tests project causes errors when trying to compile in Visual Studio 2012.
"manifest references file vstest.executionengine which is not part of the payload"
metrolog project is not compatibled for Windows 8.1.
how use this project.
I downloaded the sample codes on https://github.com/mbrit/MetroLog and upon deploying the app (WP8Sample) I have encountered the following exceptions.
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll
An exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll
An exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module. and wasn't handled before a managed/native boundary
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\en-US\mscorlib.debug.resources.dll'. Module was built without symbols.
An exception of type 'System.MissingMethodException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
A first chance exception of type 'System.MissingMethodException' occurred in mscorlib.ni.dll
An exception of type 'System.MissingMethodException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
I would like to ask if there is something wrong with my configuration or these exceptions are an issue and if there is a way to fix them other than customizing the metrolog code itself.
It seems that the current implementation does not support using SQLite targets with WinJS.
This would be a very nice addition to the features
...otherwise they'll just fill up the device.
There is a MetroLog.LogConfigurator class both in the NetCore and NetFx libraries. In my opinion, these should be named differently so it's more obvious and easy to tell them apart.
LoggingEnvironment is another class like this.
Test
Instead of this code:
if (this.Log.IsInfoEnabled)
this.Log.Info("I've been navigated to.");
It would be nice to be able to eliminate the "if"... since the "Log" knows its own flag, it's redundant to check and then call.
If you're trying to avoid computation with a non-trivial string setup, you can add an override that takes an expression (Func) like this:
this.Log.Info(() => {
// ... expensive computational calls to generate the message
return msg;
}).
This would allow the log to check the flag for itself and then decide whether or not to execute the lambda expression.
It would make client code much cleaner looking.
A bridge between MetroLog and NLog or log4net would allow you to log from your portable code, but use all the functionality that these other libraries provide when running on platforms they support.
System.TypeInitializationException: The type initializer for 'MetroLog.LazyFlushManager' threw an exception. ---> System.Exception: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
at Windows.UI.Xaml.Application.get_Current()
at MetroLog.LazyFlushManager..cctor() in c:\Users\Oren\Documents\Git\MetroLog\MetroLog.NetCore\LazyFlushManager.cs:line 58
--- End of inner exception stack trace ---
at MetroLog.LazyFlushManager.Initialize(ILogManager manager) in c:\Users\Oren\Documents\Git\MetroLog\MetroLog.NetCore\LazyFlushManager.cs:line 94
at MetroLog.LogConfigurator.OnLogManagerCreated(ILogManager manager) in c:\Users\Oren\Documents\Git\MetroLog\MetroLog.NetCore\LogConfigurator.cs:line 25
at MetroLog.LogManagerFactory.CreateLogManager(LoggingConfiguration config) in c:\Users\Oren\Documents\Git\MetroLog\MetroLog\LogManagerFactory.cs:line 39
at MetroLog.LogManagerFactory.<.cctor>b__0() in c:\Users\Oren\Documents\Git\MetroLog\MetroLog\LogManagerFactory.cs:line 21
at System.Lazy`1.CreateValue()
I've successfully added MetroLog via NuGet to my Windows Store app but when I try to do the same in a Windows Phone 8 class library It fails to build when trying to find the targets, it appears like I only find the abstract classes like AsyncTarget and BufferedTarget.
I am seeing the below exception when attempting to use the FileStreamingTarget in a universal Windows Phone 8.1 app.
I think the issue is that the NuGet package does not have the right version of MetroLog.Platform. The source code shows that you are aware of this issue and uses a conditional compilation statement for WINDOWS_PHONE_APP to work around it. However, if I decompile the version of MetroLog.Platform distributed for Wpa81 apps, I see that WINDOWS_PHONE_APP was not defined and QueryOptions is called.
System.NotImplementedException: The method or operation is not implemented.
at Windows.Storage.Search.QueryOptions..ctor(CommonFileQuery query, IEnumerable`1 fileTypeFilter)
at MetroLog.WinRTFileTarget.<DoCleanup>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at MetroLog.Targets.FileTargetBase.<CheckCleanupAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at MetroLog.Targets.FileTargetBase.<WriteAsyncCore>d__b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at MetroLog.Targets.Target.<WriteAsync>d__0.MoveNext()
If the MetroLog.NetFx or MetroLog.NetCore library can't be found, the portable MetroLog library should still work, using the configuration from LogConfiguratorBase.
Change LogLevel
at runtime without requiring an application restart.
In the App.xaml.cs
file I initialize the targets I want my logger to have as such:
LogManagerFactory.DefaultConfiguration.AddTarget(LogLevel.Trace, LogLevel.Fatal,
new FileStreamingTarget(new SingleLineLayout()));
As far as I have understood, this is the only place you set min and max LogLevel
for any given target.
As LogManagerFactory.DefaultConfiguration
doesn't let you list, get or remove any previously added targets, I cant change a targets LogLevel
configurations at runtime.
Neither can I remove it and just add a new one with the new configurations.
http://digitalmindignition.wordpress.com/2012/10/12/finding-the-device-id-in-windows-8/
http://www.wadewegner.com/2012/09/getting-the-application-id-and-hardware-id-in-windows-store-applications/
private string GetHardwareId()
{
var token = HardwareIdentification.GetPackageSpecificToken(null);
var hardwareId = token.Id;
var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);
byte[] bytes = new byte[hardwareId.Length];
dataReader.ReadBytes(bytes);
return BitConverter.ToString(bytes);
}
Hi Matt,
Nice work on getting this going for metro.
When I use a method that takes a format string and parameters, I usually expect them to just be params object []. This makes sense as you can just pass these straight through to string.Format()
What are your thoughts on this?
Matt,
What license applies to MetroLog? Have you considered releasing it with a commercially compatible license?
I get a lot of this when running unit tests. I see some references in the code to a mode/config for running under test. Is there an easy way?
7|2013-08-06T20:29:47.3249436+00:00|TRACE|7|Logging operation failed. --> System.TypeInitializationException: The type initializer for 'MetroLog.LogWriteContext' threw an exception. ---> System.PlatformNotSupportedException: This API is not supported on this platform.
at MetroLog.Internal.PlatformAdapter.Resolve[T](Boolean throwIfNotFound, Object[] args)
at MetroLog.LogWriteContext..cctor()
--- End of inner exception stack trace ---
at MetroLog.LogWriteContext..ctor()
at MetroLog.Internal.Logger.LogInternal(LogLevel level, String message, Object[] ps, Exception ex, Boolean doFormat)
Hi,
An exception of type 'System.IO.FileLoadException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\en-US\mscorlib.debug.resources.dll'. Module was built without symbols.
An exception of type 'System.MissingMethodException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
An exception of type 'System.MissingMethodException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
Note: The sample code is a Windows Phone7 app. I converted it to Windows Phone 8 app then run it with MetroLog referenced.
Here's the code I added to Application_Launching() method:
ILogger log;
LoggingConfiguration loggingConfiguration = new LoggingConfiguration();
loggingConfiguration.IsEnabled = true;
loggingConfiguration.AddTarget(LogLevel.Trace, LogLevel.Fatal, new DebugTarget());
log = LogManagerFactory.CreateLogManager(loggingConfiguration).GetLogger<App>();
log.Warn("Application_Launching");
At LogManagerFactory.CreateLogManager(loggingConfiguration), the exceptions are generated. Is this a known issue? If yes, when will it be fixed? I can reproduce this exception on MetroLog v0.8.6. Did I miss anything that should be included?
This does not cause the application to crash but it would be good to know why this happens and if poses a risk on the application using the logger.
Given an Async task like this: var task = _context.CreateTableAsync<Friend>();
If you want to log something when this task end, you should actually do:
task.ContinueWith(t =>
{
this.Debug("Table created");
});
What if instead we could do directly:
_context.CreateTableAsync<Friend>().DebugAtEnd(this, "Table created");
I implemented this new extension method like that:
public static async Task<LogWriteOperation[]> DebugAtEnd<T>(this Task<T> task, ILoggable loggable, string message, Exception ex = null)
{
Task<LogWriteOperation[]> result = null;
await task.ContinueWith(t =>
{
result = loggable.Debug(message, ex);
});
return await result;
}
What do you think about this proposal?
PS: it's applicable to all LogLevel of course.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.