diff --git a/src/NLog.Fluentd/FluentdPacker.cs b/src/NLog.Fluentd/FluentdPacker.cs
index 688fa35..230ada8 100644
--- a/src/NLog.Fluentd/FluentdPacker.cs
+++ b/src/NLog.Fluentd/FluentdPacker.cs
@@ -17,6 +17,12 @@ internal class FluentdPacker
private static DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
private readonly Packer packer;
+ ///
+ /// Packs an event in the stream.
+ ///
+ ///
+ /// The event is packed using the Message Mode.
+ ///
public void Pack(DateTime timestamp, string tag, IDictionary data)
{
@@ -27,9 +33,13 @@ public void Pack(DateTime timestamp, string tag, IDictionary dat
this.packer.Pack(data, SerializationContext);
}
+ ///
+ /// Initializes a new instance of MsgPack.Packer
+ ///
+ /// Stream object to be wrapped by the Packer
public FluentdPacker(Stream stream)
{
- this.packer = Packer.Create(stream);
+ this.packer = Packer.Create(stream);
}
private static SerializationContext InstantiateSerializationContext()
diff --git a/src/NLog.Fluentd/FluentdTarget.cs b/src/NLog.Fluentd/FluentdTarget.cs
index 18d31cd..e08b45a 100644
--- a/src/NLog.Fluentd/FluentdTarget.cs
+++ b/src/NLog.Fluentd/FluentdTarget.cs
@@ -17,7 +17,6 @@ namespace NLog.Fluentd
public partial class FluentdTarget : TargetWithLayout, IFluentdTarget
{
private string _fluentdHost;
- private string _fluentdTag;
private bool _fluentdEnabled;
private TcpClient _client;
private Stream _stream;
@@ -178,25 +177,24 @@ protected override void Write(LogEventInfo logEvent)
_fluentdEnabled = bool.Parse(Enabled?.Render(logEvent));
if (!_fluentdEnabled)
{
- InternalLogger.Trace("Fluentd is disabled.");
+ InternalLogger.Trace("Fluentd target is disabled.");
return;
}
- string renderedFluentdHost = Host?.Render(logEvent);
- _fluentdTag = Tag?.Render(logEvent);
+ CheckConnectionIsValid(Host.Render(logEvent));
+
+ string fluentdTag = Tag?.Render(logEvent);
+ Dictionary record = new Dictionary();
+ record.Add("message", Layout.Render(logEvent));
- CheckConnectionIsValid(renderedFluentdHost);
- InternalLogger.Trace("Fluentd (Name={0}): Sending to address: '{1}:{2}'", Name, _fluentdHost, Port);
- var record = new Dictionary();
- var logMessage = Layout.Render(logEvent);;
- record.Add("message", logMessage);
try
{
- this._packer.Pack(logEvent.TimeStamp, _fluentdTag, record);
+ InternalLogger.Trace("Fluentd (Name={0}): Sending to address: '{1}:{2}'", Name, _fluentdHost, Port);
+ this._packer.Pack(logEvent.TimeStamp, fluentdTag, record);
}
catch (Exception ex)
{
- InternalLogger.Warn("Fluentd Emit - " + ex.ToString());
+ InternalLogger.Warn("Fluentd: Error Packing event - " + ex.ToString());
ResetConnection();
throw; // Notify NLog of failure
}