Giter Site home page Giter Site logo

novotnyllc / metrolog Goto Github PK

View Code? Open in Web Editor NEW
145.0 145.0 83.0 3.13 MB

A lightweight logging system designed specifically for Windows Store and Windows Phone 8 apps.

License: MIT License

C# 93.98% ASP 0.08% CSS 2.13% HTML 1.10% JavaScript 2.72%

metrolog's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

metrolog's Issues

SQLite Target not available from Nuget

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?

Add hardware ID to WS LoggingEnvironment (notes)

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);
}

Improve Instructions for getting the logs of the Devices

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.

Update Readme and Sample Code

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.

  1. In App.xaml.cs:
    • sealed partial class App : ILoggable.
    • Declare a private readonly Logger _log;
    • In the constructor, set _log = LogManager.GetLogger(this, LogManager.DefaultConfiguration);
    • In the constructor, UnhandledException += App_UnhandledException;
    • void App_UnhandledException(object sender, UnhandledException e) { _log.Fatal("Fatal exception.", e.Exception); }
  2. In Home.xaml.cs:
    a. public sealed partial class Home : ILoggable
    b. Same as 1.b above.
    c. Same as 1.c above.
    d. Before loading data, _log.Info("Loading data...");
    e. Before loading webcam, 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!

Running under unit test context - supported?

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)

Various struggles with getting MetroLog to work in .winmd files - background tasks

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()

Change LogLevel at runtime

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.

Using Metrolog in iOS Results in System.TypeInitializationException

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)

JsonPostTarget fails with InvalidOperationException in Windows Store app

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?

Portable File Target

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)

Exceptions encountered on exploring sample codes

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.

MetroLog.NetCore.Tests cause errors

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"

Can't use SQLite from WinJS

It seems that the current implementation does not support using SQLite targets with WinJS.

This would be a very nice addition to the features

Proposal: Extensions methods to do logging when Task<T> end

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.

NuGet package fails to install for fresh WinJS app

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

  • Install-Package -Verbose MetroLog
  • - CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    - FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
    

No targets available in Windows Phone 8?

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.

Feature request: LogManagerFactory.DefaultConfiguration.AllTargets

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;

use params object[] args instead of params string[] ps

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?

MetroLog needs a license

Matt,

What license applies to MetroLog? Have you considered releasing it with a commercially compatible license?

System.NotImplmentedException using FileStreamingTarget in universal Windows Phone 8.1 app

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()

Check flags internally instead of "IsXEnabled/X()" pattern

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.

Logging is disbled by default

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.

No GlobalCrashHandler equivalent for WinJS

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.

Use a reasonable default configuration if LogManagerFactory.Initialize() hasn't been called

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).

LogManagerFactory.CreateLogManager(loggingConfiguration) generates FileLoadException and MissingMethodException on app start-up

Hi,

Using MetroLog v0.8.6 in the MSDN sample code (button effects.zip) below generates a FileLoadException and MissingMethodException:

http://code.msdn.microsoft.com/Button-Effects-by-Anwar-4dc1d97f

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.

Add NeutralResourcesLanguageAttribute to portable assembly

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).

Create log targets for NLog and/or log4net

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.