Implementing cross-platform logging
Now that we have our IoC container, we are going to use dependency injection for logging. Adding customized logging features in cross-platform applications is very useful for tracking operations between all of the different projects. The first step is to add a new folder called Logging
, add a new file called ILogger.cs
, and implement the following:
public interface ILogger { #region Methods void WriteLine(string message); void WriteLineTime(string message, params object[] args); #endregion }
For this example, our logger is going to use the standard Debug
console from System.Diagnostics
with iOS, but in Android we are going to use the extensive logging functionality provided by Android.
Now let's add the Logging ...
Get Xamarin Blueprints now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.