简体   繁体   中英

Library for Logging in Xamarin and error reporting style in MetroLog

I am an iOS developer which has been asked to do development in Xamarin. I want to log the outputs in Xamarin.

I am trying to find a library for this. I found one library for this called MetroLog.

Link : https://github.com/onovotny/MetroLog

But the problem is I am getting blue coloured output for every log level.Like this: 在此输入图像描述

I was expecting that the errors would be in red , warnings would be in orange, and others in green or blue or something, but I could not get the required output in the manner I thought I would. I am running sample project from their repo , which has source code as follows:

_log.Info("Information - We are about to do magic!");
_log.Warn("Warning!");
_log.Trace("Trace some data.");
_log.Error("Something bad happened at {0}", DateTime.Now);
_log.Fatal("Danger Will Robinson!");
  1. Are there some changes that I need to make to the logging project when it has been added to my project?

  2. Is there any other library which can solve my use case for logging ?

  3. If not then how can I achieve similar and coloured option from MetroLog ? I am open to other options(open source project) as well.

MORE INFO or EXTENDED QUESTION:

As I am used to iOS development I used to use the following statements in order to log the information:

NSLog(@"%@  %@ started" ,[self class] ,NSStringFromSelector(_cmd));
NSLog(@"%@  %@ ends   " ,[self class] ,NSStringFromSelector(_cmd));

I am expecting some sort of quick logging option like the one for iOS as shown above without including any library. Is that possible?( including the class name and the method name which is executing the code)

Thanks.

I have not use MetroLog but, in general, such libraries requires you to set a destination / endpoint / server for your logs. The default one is often the basic one offered by the OS (which is the one that Xamarin Studio will redirect) and that won't give you coloured output.

Quick Logging : Every string given to System.Console.WriteLine ends up calling NSLog on iOS. Since that's part of mscorlib.dll (SDK) there's nothing else you'll need to add to your project to use it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM