Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer support in log4net-loggly library during network outage #3

Merged
merged 4 commits into from Jan 28, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

make buffer option configurable

  • Loading branch information
Shwetajain148 committed Jan 24, 2017
commit 2bc79d508ee352fc3c7ce473a189ba40ed88ccb6
@@ -10,5 +10,6 @@ public interface ILogglyAppenderConfig
string Tag { get; set; }
string LogicalThreadContextKeys { get; set; }
string GlobalContextKeys { get; set; }
int BufferSize { get; set; }
}
}
@@ -24,6 +24,7 @@ public class LogglyAppender : AppenderSkeleton
public string Tag { set { Config.Tag = value; } }
public string LogicalThreadContextKeys { set { Config.LogicalThreadContextKeys = value; } }
public string GlobalContextKeys { set { Config.GlobalContextKeys = value; } }
public int BufferSize { set { Config.BufferSize = value; } }

private LogglyAsyncHandler LogglyAsync;

@@ -43,6 +43,7 @@ public string LogMode

public string GlobalContextKeys { get; set; }

public int BufferSize { get; set; }
public LogglyAppenderConfig()
{
UserAgent = "loggly-log4net-appender";
@@ -51,6 +52,7 @@ public LogglyAppenderConfig()
LogMode = "bulk";
LogicalThreadContextKeys = null;
GlobalContextKeys = null;
BufferSize = 500;
}
}
}
@@ -18,6 +18,7 @@ public class LogglyBufferringAppender : BufferingAppenderSkeleton
public string LogMode { set { Config.LogMode = value; } }
public int TimeoutInSeconds { set { Config.TimeoutInSeconds = value; } }
public string Tag { set { Config.Tag = value; } }
public int BufferSize { set { Config.BufferSize = value; } }

protected override void Append(LoggingEvent loggingEvent)
{
@@ -6,14 +6,13 @@ namespace log4net.loggly
{
class LogglyStoreLogsInBuffer
{
public static int bufferSize = 500;
public static List<string> arrBufferedMessage = new List<string>();
public static List<string> tempList = new List<string>();

public static void storeBulkLogs(ILogglyAppenderConfig config, List<string> logs, bool isBulk)
{
if (logs.Count == 0) return;
int numberOfLogsToBeRemoved = (arrBufferedMessage.Count + logs.Count) - bufferSize;
int numberOfLogsToBeRemoved = (arrBufferedMessage.Count + logs.Count) - config.BufferSize;
if (numberOfLogsToBeRemoved > 0) arrBufferedMessage.RemoveRange(0, numberOfLogsToBeRemoved);

arrBufferedMessage = logs.Concat(arrBufferedMessage).ToList();
@@ -22,7 +21,7 @@ public static void storeBulkLogs(ILogglyAppenderConfig config, List<string> logs
public static void storeInputLogs(ILogglyAppenderConfig config, string message, bool isBulk)
{
if (message == String.Empty) return;
int numberOfLogsToBeRemoved = (arrBufferedMessage.Count + 1) - bufferSize;
int numberOfLogsToBeRemoved = (arrBufferedMessage.Count + 1) - config.BufferSize;
if (numberOfLogsToBeRemoved > 0) arrBufferedMessage.RemoveRange(0, numberOfLogsToBeRemoved);
arrBufferedMessage.Add(message);
}
@@ -50,7 +50,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ILogglyAppenderConfig.cs" />
<Compile Include="ILogglyBufferedLogs.cs" />
<Compile Include="ILogglyClient.cs" />
<Compile Include="LogglyAppenderConfig.cs" />
<Compile Include="LogglyAsyncHandler.cs" />
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.