fluent / fluent/NLog.Targets.Fluentd

Fallback doesn't seem to be working

Open
#11 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
46
Forks
31
PR merge metrics
No merged PRs in 30d

Description

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) :
``` csharp
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
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.