GithubHelp home page GithubHelp logo

serilog / serilog-sinks-xamarin Goto Github PK

View Code? Open in Web Editor NEW
54.0 15.0 18.0 74 KB

A Serilog sink that writes events to Xamarin mobile targets

License: Apache License 2.0

C# 86.17% PowerShell 13.83%
serilog-sink xamarin android ios serilog dotnet

serilog-sinks-xamarin's Introduction

Serilog.Sinks.Xamarin Build status Join the chat at https://gitter.im/serilog/serilog

Writes Serilog events to the console of Xamarin.iOS (NSLog) / Xamarin.Android (AndroidLog).

Getting started

Install from NuGet:

Install-Package Serilog.Sinks.Xamarin

When using Xamarin.iOS

Log.Logger = new LoggerConfiguration()
    .WriteTo.NSLog()
    .CreateLogger();

When using Xamarin.Android

Log.Logger = new LoggerConfiguration()
    .WriteTo.AndroidLog()
    .Enrich.WithProperty(Constants.SourceContextPropertyName, "MyCustomTag") //Sets the Tag field.
    .CreateLogger();

Within your portable class libary or within your application

Log.Information("This will be written to either NSLog or AndroidLog");

Because the memory buffer may contain events that have not yet been written to the target sink, it is important to call Log.CloseAndFlush() or Logger.Dispose() when the application/activity exits.

serilog-sinks-xamarin's People

Contributors

chucker avatar ghuntley avatar kensykora avatar merbla avatar nblumhardt avatar nickrandolph avatar petrol- avatar rlittlesii avatar

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

Watchers

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

serilog-sinks-xamarin's Issues

Bug: Namespace Xamarin does not exist

Note: for support questions, please ask on StackOverflow: https://stackoverflow.com/questions/tagged/serilog . This repository's issues are reserved for feature requests and bug reports.

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

It seems the dll being built doesn't have file inside.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

Install Serilog.Sinks.Xamarin 02.0.57

What is the expected behavior?

It should resolve Serilog.Sinks.Xamarin

What is the motivation / use case for changing the behavior?

I consolidated projects to a single project, in hopes to make maintenance easier. I mus have overlooked a step as the files don't seem to load to the dll's output.

Which versions of Serilog, and which platform / OS are affected by this issue? Did this work in previous versions of Serilog?

Version 0.2.0.57

https://www.nuget.org/packages/Serilog.Sinks.Xamarin/0.2.0.57

Other information (e.g. stacktraces, related issues, suggestions how to fix)

Compatibility with dotnet maui

It looks like serilog-sinks-xamarin is not compatible with dotnet maui:
Package Serilog.Sinks.Xamarin 0.2.0.64 is not compatible with net6.0-ios15.2

Is there another package for Maui (instead of Xamarin) ?
Or do you plan to update this package ?
Or maybe there is a workaround for this issue ?

Can't add Serilog.Sinks.Xamarin to PCL project

Can't add Serilog.Sinks.Xamarin to PCL project. Try to add Serilog and Newtonsoft.Json before adding Serilog.Sinks.Xamarin but still doesn't work.

Here is packahe console output:

Attempting to gather dependency information for package 'Serilog.Sinks.Xamarin.0.1.18' with respect to project 'test', targeting '.NETPortable,Version=v4.5,Profile=Profile259'
Attempting to resolve dependencies for package 'Serilog.Sinks.Xamarin.0.1.18' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Serilog.Sinks.Xamarin.0.1.18'
Resolved actions to install package 'Serilog.Sinks.Xamarin.0.1.18'
For adding package 'Serilog.Sinks.Xamarin.0.1.18' to project 'test' that targets 'portable45-net45+win8+wp8+wpa81'.
Install failed. Rolling back...
Package 'Serilog.Sinks.Xamarin.0.1.18 : Newtonsoft.Json [0.0.0-alpha, ), Serilog [0.0.0-alpha, )' does not exist in project 'test'
Could not install package 'Serilog.Sinks.Xamarin 0.1.18'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

AndroidLog cannot be found

Note: for support questions, please ask on StackOverflow: https://stackoverflow.com/questions/tagged/serilog . This repository's issues are reserved for feature requests and bug reports.

Do you want to request a feature or report a bug?
bug

What is the current behavior?

'LoggerSinkConfiguration' does not contain a definition for 'AndroidLog' and no extension method 'AndroidLog' accepting a first argument of type 'LoggerSinkConfiguration' could be found (are you missing a using directive or an assembly reference?)

Serilog.Sinks.Xamarin.Droid (v0.1.29) has been installed on android project.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

  1. Install Serilog.Sinks.Xamarin.Droid on android project.
  2. Log.Logger = new LoggerConfiguration()
    .WriteTo.AndroidLog();
    .CreateLogger()

What is the expected behavior?
AndroidLog should be found.

What is the motivation / use case for changing the behavior?
This is minimal initial setup.

Which versions of Serilog, and which platform / OS are affected by this issue? Did this work in previous versions of Serilog?
Serilog: v2.4.0

Other information (e.g. stacktraces, related issues, suggestions how to fix)

Support Apple Unified Logging

Do you want to request a feature or report a bug?
Feature

What is the current behavior?
Only supports NSLog on iOS

What is the motivation / use case for changing the behavior?
Support Unified Logging

UWP Support for xamarin

Do you want to request a feature or report a bug?
Feature

What is the current behavior?
Works on Android and iOS

What is the expected behavior?
Also works for Xamarin Forms UWP builds

What is the motivation / use case for changing the behavior?
Developing x-platform apps targeting 3 platforms

Which versions of Serilog, and which platform / OS are affected by this issue? Did this work in previous versions of Serilog?
UWP

Additional Notes
If there is already a portable version that can be used for UWP using something such as a dependency service (if uwp integration won't be implemented into this version of serilogs), then can you please link me to this?

support xamarinmac20?

Do you want to request a feature or report a bug?

  • feature

What is the current behavior?
Cannot install nuget package to xamarinmac20 (Xamarin Mac Mobile Framework)

What is the expected behavior?
Can install and it works!

What is the motivation / use case for changing the behavior?
Support Xamarin.Mac which is parallel to Xamarin iOS and Android anyway

Which versions of Serilog, and which platform / OS are affected by this issue? Did this work in previous versions of Serilog?
Latest, Mac OS El Capitan+ (use Xamarin Studio to test)

Other information (e.g. stacktraces, related issues, suggestions how to fix)

warning CA1416: This call ... is only supported on: 'Android' 31.0 / 'iOS' 15.4 and later.

Bug report

When building a maui app referencing Serilog.Sinks.Xamarin 1.0.0, I get the following warnings:

warning CA1416: This call site is reachable on: 'iOS' 15.0 and later, 'maccatalyst' 15.0 and later. 'LoggerConfigurationXamarinExtensions.NSLog(LoggerSinkConfiguration, LogEventLevel, string, IFormatProvider)' is only supported on: 'iOS' 15.4 and later
warning CA1416: This call site is reachable on: 'Android' 21.0 and later. 'LoggerConfigurationXamarinExtensions.AndroidLog(LoggerSinkConfiguration, LogEventLevel, string, IFormatProvider)' is only supported on: 'Android' 31.0 and later

Indeed, here are the supported platform versions as visible in the Serilog.Sinks.Xamarin 1.0.0 nuget's assemblies:

[assembly: SupportedOSPlatform("Android31.0")]
[assembly: SupportedOSPlatform("iOS15.4")]

The reason for it is that serilog-sinks-xamarin is missing SupportedOSPlatformVersion in its csproj:

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>

Could you please fix that and publish a new version of the nuget ?
Thanks

newline not working in DefaultAndroidLogOutputTemplate

This bug is in the nitpick category. Most recently observed in Serial.Sinks.Xamarin 1.0.0.

In src/Serilog.Sinks.Xamarin/Sinks/Xamarin/android/LoggerConfigurationXamarinExtensions.cs, the default output template is:
const string DefaultAndroidLogOutputTemplate = "[{Level}] {Message:l{NewLine:l}{Exception:l}";

The above does not produce a newline between Message and Exception, so the message and exception are jammed together.

This change produces the intended effect, where a newline precedes the exception:
"[{Level}] {Message:l}{NewLine}{Exception:l}"

I can pass my fix via outputTemplate in AndroidLog(), but wondering if the default could be fixed.

Serilog.Sinks.Xamarin NuGet can not be added for iOS and Android

Issue

this is impossible to add Serilog.Sinks.Xamarin for both iOS and Android projects. Tried all versions of the sink (0.1.14 - 0.1.18).

The following error appeared (e.g. for Android):

Attempting to gather dependency information for package 'Serilog.Sinks.Xamarin.0.1.18' with respect to project 'test.Droid', targeting 'MonoAndroid,Version=v6.0'
Attempting to resolve dependencies for package 'Serilog.Sinks.Xamarin.0.1.18' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Serilog.Sinks.Xamarin.0.1.18'
Resolved actions to install package 'Serilog.Sinks.Xamarin.0.1.18'
For adding package 'Serilog.0.1.6' to project 'test.Droid' that targets 'monoandroid60'.
Install failed. Rolling back...
Package 'Serilog.0.1.6' does not exist in project 'test.Droid'
Package 'Serilog.0.1.6' does not exist in folder ...
Could not install package 'Serilog 0.1.6'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v6.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Environment

Xamarin Studio Community
Version 6.1.1 (build 15)
Installation UUID: XXX
Runtime:
Mono 4.6.1 (mono-4.6.0-branch-c8sr0/abb06f1) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Package version: 406010003

NuGet
Version: 3.4.3.0

Xamarin.Profiler
Not Installed

Apple Developer Tools
Xcode 7.3.1 (10188.1)
Build 7D1014

Xamarin.Android
Version: 7.0.1.2 (Xamarin Studio Community)
Android SDK: /Users/XXX/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
6.0 (API level 23)

SDK Tools Version: 25.1.2
SDK Platform Tools Version: 24.0.0
SDK Build Tools Version: 23.0.2

Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Xamarin Android Player
Not Installed

Xamarin.iOS
Version: 10.0.1.8 (Xamarin Studio Community)
Hash: 3983064
Branch: cycle8-sr0-xi
Build date: 2016-09-23 15:34:54-0400

Xamarin.Mac
Version: 2.10.0.103 (Xamarin Studio Community)

Build Information
Release ID: 601010015
Git revision: fa52f02641726146e2589ed86ec4097fbe101888
Build date: 2016-09-22 08:03:02-04
Xamarin addins: 75d65712af93d54dc39ae4c42b21dfa574859fd6
Build lane: monodevelop-lion-cycle8-sr0

not compatible with .NetStandard

I am trying to install the Xamarin Sink for Serilog but I get the following error:
Package Serilog.Sinks.Xamarin 0.1.29 is not compatible with netstandard1.3 (.NETStandard,Version=v1.3).
Are then plans to support .NetStandard?

.NET 7 Support?

Note: for support questions, please ask on StackOverflow: https://stackoverflow.com/questions/tagged/serilog . This repository's issues are reserved for feature requests and bug reports.

Do you want to request a feature or report a bug?
Feature

What is the current behavior?
Package cannot be installed to .NET projects (notably MAUI)

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

What is the expected behavior?
Package installs without issue

What is the motivation / use case for changing the behavior?
.NET 7 launched and the Serilog package now supports .NET 7

Which versions of Serilog, and which platform / OS are affected by this issue? Did this work in previous versions of Serilog?
N/A

Other information (e.g. stacktraces, related issues, suggestions how to fix)

Setting Tag for Android

It's not obvious how to set the Tag field for the android logcat. Could you perhaps add example code to demonstrator how to set this?

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.