GithubHelp home page GithubHelp logo

nlog.targets.fluentd's Introduction

NLog.Targets.Fluentd

NLog.Targets.Fluents is a custom target of NLog that emits the log entries to a fluentd node.

Settings

Setting Description Example
Host Host name of the fluentd node example.local
Port Port number of the fluentd node 24224
Tag Fluentd tag name windowshost
NoDelay Enable Nagle's algorithm true
SendBufferSize Send buffer size 8192
SendTimeout Send timeout 2
LingerEnabled Wait for all the data to be sent when closing the connection false
LingerTime Linger timeout 2
EmitStackTraceWhenAvailable Emit a stacktrace for every log entry when available false
IncludeAllProperties Include structured logging parameters for every log entry false

License

NLog.Targets.Fluentd

Copyright (c) 2014 Moriyoshi Koizumi and contributors.

This software is licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

nlog.targets.fluentd'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

Watchers

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

nlog.targets.fluentd's Issues

Enable asynchronous operation

I had planned to use the NLog.Targets.Fluentd target in my projects. However, I have encountered an issue with it. Messages sent to Fluentd are being sent synchronously, which is causing a slowdown in the main process. Furthermore, in cases where Fluentd is unavailable, the flow is blocked until a timeout is reached.

I have made modifications to the project to enable asynchronous operation and have added basic buffering to ensure that logs are not lost when the application is stopped.

Please let me know if you would be interested in incorporating such a feature.

Fallback doesn't seem to be working

Logs are being sent to the local fluentd instance just fine, and with the forwarding rules in place, are being transmitted out to the main aggregator instance as well. However, I'm trying to make sure that if the local fluentd is not available for some reason, that the logs will be written to a local file to be gathered manually when we fix the problem.

If I kill the local fluentd instance, so that the connection will fail, the fallback target is not being called and no log file is present in the given directory. Am I missing something, or configured something incorrectly?

Here is my config (I was messing with the timeout and buffer sizes thinking that may have something to do with it) :

var logLayout = new SimpleLayout("${longdate} [${level}] ${message} ${exception}");
var config = new LoggingConfiguration();

var fallbackTarget = new FallbackGroupTarget
{
    Name = "fluentd-fallback",
    ReturnToFirstOnSuccess = false
};

var fluentdTarget = new Fluentd
{
    Name = "fluentd",
    Layout = logLayout,
    NoDelay = true,
    SendTimeout = 1,
    ReceiveTimeout = 1,
    LingerEnabled = false,
    Tag = "new-api"
};

var fileTarget = new FileTarget
{
    Name = "fluentd-file-fallback",
    FileName = "C:\\logs\\fluent-failed.txt",
    Layout = logLayout,
    Encoding = Encoding.UTF8
};

fallbackTarget.Targets.Add(fluentdTarget);
fallbackTarget.Targets.Add(fileTarget);

var bufferWrapper = new BufferingTargetWrapper
{
    Name = "fluentd-buffer",
    OverflowAction = BufferingTargetWrapperOverflowAction.Flush,
    SlidingTimeout = true,
    WrappedTarget = fallbackTarget,
    BufferSize = 1,
    FlushTimeout = 50
};

config.AddTarget("fluentd-buffer", bufferWrapper);
config.AddRuleForAllLevels(bufferWrapper);

var loggerFactory = new LogFactory(config)
{
    ThrowConfigExceptions = true,
    ThrowExceptions = true
};

InternalLogger.LogFile = "C:\\logs\\nlog-internal.txt";
InternalLogger.LogLevel = LogLevel.Debug;

return loggerFactory.GetLogger("burtonr");

I should note that the internal log does appear, so there shouldn't be any issues with the file system permissions. The internal log file looks like this:

2018-12-24 18:17:31.0025 Debug Targets for fluentd-fallback by level:
2018-12-24 18:17:31.0194 Debug Trace => fluentd-fallback
2018-12-24 18:17:31.0345 Debug Debug => fluentd-fallback
2018-12-24 18:17:31.0345 Debug Info => fluentd-fallback
2018-12-24 18:17:31.0506 Debug Warn => fluentd-fallback
2018-12-24 18:17:31.0506 Debug Error => fluentd-fallback
2018-12-24 18:17:31.0665 Debug Fatal => fluentd-fallback
2018-12-24 18:18:05.2545 Debug Targets for burtonr by level:
2018-12-24 18:18:05.2702 Debug Trace => fluentd-buffer
2018-12-24 18:18:05.2702 Debug Debug => fluentd-buffer
2018-12-24 18:18:05.2702 Debug Info => fluentd-buffer
2018-12-24 18:18:05.2858 Debug Warn => fluentd-buffer
2018-12-24 18:18:05.2858 Debug Error => fluentd-buffer
2018-12-24 18:18:05.2858 Debug Fatal => fluentd-buffer

how to config

Hi,
Below are my config and program, for some reason I didn't get message logged. Did I do anything apparently wrong. I tried your Demo app, and it's not working either.

//NLog.config
capture

//Program.cs
class Program
{
private static Logger logger = LogManager.GetCurrentClassLogger();
static void Main(string[] args)
{
logger.Info("sending from NLog");
}
}

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.