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

Conversation

@Shwetajain148
Copy link

@Shwetajain148 Shwetajain148 commented Jan 20, 2017

  • Store logs during network outage.
  • Rotate stored logs while running out of memory.
  • Send buffered logs after re-connection.
  • Handle bad token error.
  • Truncate event over 1 MB size.
  • Make buffer option configurable.
  • Refactor: Fix linting issue(Library follow mixed spacing tab and 4 spaces)
  • Testing
@Shwetajain148 Shwetajain148 changed the title initial commit for buffer support in log4net-loggly library Buffer support in log4net-loggly library during network outage Jan 20, 2017
}

catch (WebException e) {
var response = (HttpWebResponse)e.Response;

This comment has been minimized.

@mchaudhary

mchaudhary Jan 24, 2017

Will this generate Null exception ?

{
if (response.StatusCode == HttpStatusCode.Forbidden) //Check for bad token
{
setValidInvalidFlag(false);

This comment has been minimized.

@mchaudhary

mchaudhary Jan 24, 2017

This function name is pretty funky setValidInvalidFlag. I think what we are doing is if we getting Forbidden error we are marking token as invalid so we should call this function setTokenValid(false).

if (totalRetries == 1) Console.WriteLine("Loggly error: {0}", e.Message);
}

else if (totalRetries == 1)

This comment has been minimized.

@mchaudhary

mchaudhary Jan 24, 2017

This logic of else if (totalRetries == 1) is also very confusing since this has no relation with above if (response != null). We should always have if and else if in conjunction. I understand what you are trying to do here. You are basically saying if there is exception and the it is not first time lets put it in buffer. I think we can make code such that it is more easy to understand.

@Shwetajain148
Copy link
Author

@Shwetajain148 Shwetajain148 commented Jan 25, 2017

@mchaudhary:
In case of network outage, response variable will be null because request to the remote server couldn't be completed.

When response is null, I am just storing logs into buffer otherwise checking for bad token error(403). Other than bad token status, we are storing logs into the buffer.

Please Review.

@mchaudhary mchaudhary merged commit 154d848 into loggly:master Jan 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.