GithubHelp home page GithubHelp logo

serilog-archive / serilog-sinks-logentries Goto Github PK

View Code? Open in Web Editor NEW
7.0 7.0 16.0 43 KB

A Serilog sink that writes events to Logentries

License: Apache License 2.0

PowerShell 7.35% C# 92.65%

serilog-sinks-logentries's People

Contributors

agecas avatar aguvenli avatar davidposin avatar jeremymeng avatar jerry2007 avatar kieranobrien-r7 avatar nblumhardt avatar nssben avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

serilog-sinks-logentries's Issues

LeClient uses synchronous writes

In LeClient.Cs, we have the following code:

public void Write(byte[] buffer, int offset, int count){ ActiveStream.Write(buffer, offset, count); }

In turn, the sync variant of EmitBatch is implemented in the sink. Is there a reason why the async implementation was not chosen?

Memory keeps growing to cause the pod to restart

I define many custom property for logEntries:

public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
//... something
foreach (var allProperty in AllProperties)
{
var data = dataContext.GetData(allProperty);
if (data != null)
{
var prop = propertyFactory.CreateProperty(allProperty, data);
logEvent.AddOrUpdateProperty(prop);
}
}
}

When I execute LogInfo repeatedly, the memory keeps growing. I ran the service in the k8s cluster and finally exceeded the 1G memory limit, causing the pod to restart.

Enrich is not working

Hello,

I have used following code for testing.
However, Logentires didn't capture the enrich machine name information.
logged "Test" only

LoggerConfiguration()
.MinimumLevel.Information()
.WriteTo.Logentries("token")
.Enrich.WithMachineName()
.CreateLogger();

Log.Information("Test");

Serilog does not log to LogEntries on Ubuntu Server 14.2

Hi,

I'm using the logentries sink and it works fine if I run my App on Windows. But when running on Ubuntu it only logs to stdout which I have configured as a second sink.

I have built the App now also on Linux with monodevelop but no change.

Any Idea how I can workaround this?
Thanks
Thomas

HowTo: Read configuration from appsettings.json

I can't seem to find the right settings for my appsettings.json so that when I use: ReadFrom.Configuration(Configuration) in my Startup.cs, Logentries will read its settings from the configuration.

This is what I have currently:

    "WriteTo": [
      {
        "Name": "LogEntries",
        "Args": {
          "token": "MY-TOKEN",
          "formatProvider": "Serilog.Formatting.Json.JsonFormatter, Serilog",
          "restrictedToMinimumLevel": "Debug" 
        }
      }
    ]

I can't seem to find any clear instructions on how to do this.

Allow sending multiple lines per event

Currently, LogentriesSink removes newline characters from events formatted as multi-line string before sending them to Logentries. This is a fine default behaviour, however, in some cases preserving multi-line formatting is preferable to preserving one-to-one mapping between Serilog log events and Logentries entries.

It would be nice to have a parameter which allows sending multiple lines per one event.

Processs order in Dispose(bool)

Hi

PeriodicBatchinSink is disposing time call CloseAndFlush(). It is processing remain queue(call OnTick).
Because I think, LogentriesSink.Dispose(boo) is this order.

        /// <summary>
        /// Dispose the connection.
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (_client != null)
            {
                _client.Flush();
                _client.Close();
            }
        }

Wrong Version Bug

Trying to run Serilog 1.5.12 but this package gave me a lot of hard to debug issues:

Could not load file or assembly 'Serilog, Version=1.4.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10' or one of its dependencies.

Downloading the project and referencing the up-to-date serilog resolve the issue for now.

It's worth noting that this was a little tricky to diagnose as it would work when running as a stand-alone, but when I called this project as part of a bigger IIS project that's when the issue arose.

System.IO.FileLoadException was unhandled
FileName=Serilog, Version=1.4.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10
FusionLog==== Pre-bind state information ===
LOG: DisplayName = Serilog, Version=1.4.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10
(Fully-specified)
LOG: Appbase = file:///C:/SourceControl/ExportApps/Services/bin/
LOG: Initial PrivatePath = NULL

Calling assembly : Serilog.Sinks.Logentries, Version=1.5.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10.

LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Serilog, Version=1.4.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10
LOG: Attempting download of new URL file:///C:/SourceControl/ExportApps/Services/bin/Serilog.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

HResult=-2146234304
Message=Could not load file or assembly 'Serilog, Version=1.4.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source=Logging
StackTrace:
at Logging.Setup.ConfigureLogging(Boolean outputToConsole)
at ExportHost.Program.Main(String[] args) in C:\SourceControl\ExportApps\ExportHost\Program.cs:line 29
InnerException:

Support for DataHub

I use LogEntries DataHub to aggregate all our logs in a local network service and push them to LogEntries API from there. It also allows us to avoid the whole TCP Token system of copying a token for every service we deploy.

The LogEntries library supported this, but not the Serilog library.

I'm going to add a PR that adds the behavior in the same way that the original LogEntries library did it.

Log before start of KestrelHttpServer locks for 20 min before opening port (Serilog.Sinks.Logentries 3.0.0-dev-00020).

Hi,

When we are doing things like this at startup:

public class Program
{
        public static void Main(string[] args)
        {
             var host = new WebHostBuilder()
                .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .Build();

            ILogger<Program> logger = host.Services.GetService(typeof(ILogger<Program>)) as ILogger<Program>;
            logger.LogInformation($"Starting application ({hostingEnvironment.EnvironmentName})");

            host.Run();
        }
}

Later inside the application we doing other serilog logging.

We will get a delay of 20 minutes before we successfully start listen on our port and all logging after this seams to work as expected.
Some threading/locking issue in Serilog.Sinks.Logentries causing this problem.
In the logging below we have turned on the "Serilog.Debugging.SelfLog.Enable(msg => Console.WriteLine(msg));" to see what serilog is doing.

The environment:
Docker inside AWS/Rancher
Docker image as base: microsoft/aspnetcore:1.0.1

Log:

2016-10-31 13:12:11 [Information] Starting application (Develop)
2016-10-31T13:31:16.4800960Z Exception while emitting periodic batch from Serilog.Sinks.Logentries.LogentriesSink: System.AggregateException: One or more errors occurred. (Connection timed out 54.217.226.25:20000) ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: Connection timed out 54.217.226.25:20000
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.Sockets.SocketTaskExtensions.<>c.<ConnectAsync>b__3_1(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- 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.ConfiguredTaskAwaiter.GetResult()
   at System.Net.Sockets.TcpClient.<ConnectAsyncCorePrivate>d__64.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Net.Sockets.TcpClient.<ConnectAsyncCorePrivate>d__64.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.ConfiguredTaskAwaiter.GetResult()
   at System.Net.Sockets.TcpClient.<ConnectAsyncCorePrivate>d__62.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Serilog.Sinks.Logentries.LeClient.Connect()
   at Serilog.Sinks.Logentries.LogentriesSink.EmitBatch(IEnumerable`1 events)
   at Serilog.Sinks.PeriodicBatching.PeriodicBatchingSink.OnTick()
---> (Inner Exception #0) System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: Connection timed out 54.217.226.25:20000
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.Sockets.SocketTaskExtensions.<>c.<ConnectAsync>b__3_1(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- 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.ConfiguredTaskAwaiter.GetResult()
   at System.Net.Sockets.TcpClient.<ConnectAsyncCorePrivate>d__64.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Net.Sockets.TcpClient.<ConnectAsyncCorePrivate>d__64.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.ConfiguredTaskAwaiter.GetResult()
   at System.Net.Sockets.TcpClient.<ConnectAsyncCorePrivate>d__62.MoveNext()<---

2016-10-31 13:31:16 [Information] Overriding kestrel server urls: http://+:5000
2016-10-31 13:31:16 [Debug] Listening on: http://+:5000
[?1h=2016-10-31 13:31:16 [Debug] Hosting starting
2016-10-31 13:31:16 [Debug] Hosting started
Hosting environment: Develop
Content root path: /dotnetapp
Now listening on: http://+:5000
Application started. Press Ctrl+C to shut down.

We have confirmed that if we remove "Serilog.Sinks.Logentries" we don't get this delay.

Any suggestions?

No logs written to log entries with newly created logentries.com account (from Rapid7)

Logentries was purchased by Rapid7 and they have different urls than the original logentries.com so this doesn't work for someone that just signs up for logentries.com

After emailing the company this is what they said.

https://github.com/serilog/serilog-sinks-logentries/blob/dev/src/Serilog.Sinks.Logentries/Sinks/Logentries/LeClient.cs (edited)
and change this line:
        `const String LeApiUrl = "data.logentries.com";`
to
        `const String LeApiUrl = "us.data.logs.insight.rapid7.com";`

This simple bit of code won't work with a new account.

            Log.Logger = new LoggerConfiguration()
                .WriteTo.Console()
                .WriteTo.Logentries("my token goes here")
                .CreateLogger();

            var logTest = Log.ForContext<SomeClass>();

            logTest.Information("hello world 1");

Maybe do something like this where source is optional and if not provided it uses the existing setting.

var log = new LoggerConfiguration()
                        .WriteTo.Logentries("token", source: LogEntriesSource.Rapid7.US)
                        .CreateLogger();

New package has wrong .nuspec

@nblumhardt Getting this error now on restore:

     Candela.Web.Customers (>= 1.0.0-P0-alpha) -> Candela.Web.Common (>= 1.0.0)
-> Candela.Frameworks.Common (>= 1.0.0) -> Serilog.Sinks.Logentries (>= 2.0.14)
-> Serilog (>= 1.4.204 && < 2.0.0).

Does this now rely only on Serilog 2.0.0 or greater?

<dependency id="Serilog" version="[1.4.204,2)" />
Should be:
<dependency id="Serilog" version="2.0.0" />

Sorry! Forgot to mention that in my previous comments before you sent this out. Didn't notice the nuspec change I'd made.

4.0.0 silently fails logging

Web API .net framework 4.7.2

version 3.0.21 logs to logentries fine, 4.0.0 fails silently.

Here's my setup to replicate.

private static void InitializeLogger(string token)
{
Log.Logger = new LoggerConfiguration().Enrich.FromLogContext()
.WriteTo.Logentries(token, outputTemplate: "[{Level}] {Message} {Properties:j}{NewLine}{Exception}").CreateLogger();
Log.Information("Log initialized.");
}

Memory keeps growing

Hi,

My apologies if this is not correct place for this issue.

I am running a .Net windows service (.net 4.6.1) with Serilog for logging. I am using Serilog.Logentries NuGet package manager to write to logentries sink ( using the latest version).

Separate loggers are created for each important class, these instances live in the memory for application lifetime.

The application crashes after running for 4-6 days due to Out Of Memory Exception. I ran ANT profiler for this and I can see most of the memory is consumed by Byte and String type.

Most of Byte memory is held by System.Net.Security._sslStream, and it keeps growing.

image

Add a durable LogEntries sink like DurableLogglySink

Serilog and LogEntries, especially with its Live Tail feature would be a great tool for Xamarin mobile development if it had a durable sink. Network connections are unreliable on mobile, and phones switch from WiFi to 4G and back, especially when developing a location monitoring app. Currently, lines are dropped when there is no connection.

A durable sink would use file based storage and then send any stored lines when the network is restored before sending new lines directly.

New organization required for this repository

Hi @serilog/reviewers-logentries ๐Ÿ‘‹

Via serilog/serilog#1627 - we're unbundling the serilog organization to help distribute the effort involved in managing the various Serilog sub-projects. The serilog organization will now only manage the fundamental sinks and other packages that the rest of the ecosystem builds upon.

If this package is actively maintained, it can be moved to a new organization managed by the maintainers. Otherwise, it can move to the serilog-archive parking lot, from where we hope a new community-run fork might spring from in the future ๐ŸŒท .

Let me know if you're a maintainer and keen to continue this project under a new org; otherwise, I'll shuffle things around and move this one to the archive.

Thanks!

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.