Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

A logger for Azure WebApps #468

Merged
merged 1 commit into from
Jul 29, 2016
Merged

A logger for Azure WebApps #468

merged 1 commit into from
Jul 29, 2016

Conversation

victorhurdugaci
Copy link
Contributor

WIP implementation for #466. Sending to get some early feedback. Tests are on the way.

Please review @pakrym @kichalla @davidfowl

}
else
{
_disposable[index - 2] = disposable;
Copy link
Contributor

@pakrym pakrym Jul 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check index or it will nullref is constructor had 1 or 2 and SetDisposable is called for index >2

@victorhurdugaci
Copy link
Contributor Author

Updated

PassLogEventToInnerSink(logEvent);
}
}
catch(OperationCanceledException)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: space after catch

@victorhurdugaci
Copy link
Contributor Author

Updated with some tests


namespace Microsoft.Extensions.Logging.Abstractions.Internal
{
public sealed class NullLogger : ILogger
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't encourage APIs in the .Internal folder referenced by other projects in the same solution. This either needs to be proper public API or shared source

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@victorhurdugaci victorhurdugaci force-pushed the victorhu/azure-logger branch from ff8a120 to 7dc5021 Compare July 28, 2016 18:14
@victorhurdugaci
Copy link
Contributor Author

Updated. I would like to push this before my vacation. If you have more comments, please add them, otherwise sign off

}

// Wait for the thread to complete before disposing the resources
_workerThread.Join();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to be defensive here and add a timeout.

@victorhurdugaci
Copy link
Contributor Author

Updated

/// </summary>
/// <param name="factory">The extension method argument</param>
/// <param name="fileSizeLimitMb">A strictly positive value representing the maximum log size in megabytes. Once the log is full, no more message will be appended</param>
public static ILoggerFactory AddAzureWebAppDiagnostics(this ILoggerFactory factory, int fileSizeLimitMb = FileLoggerProvider.DefaultFileSizeLimitMb)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code configuration will be addressed in #470

@davidfowl
Copy link
Member

@nblumhardt can you review?

@victorhurdugaci victorhurdugaci force-pushed the victorhu/azure-logger branch from e5bf597 to 5d10260 Compare July 29, 2016 20:03
if (!string.IsNullOrEmpty(config.BlobContainerUrl))
{
// TODO: Add the blob logger by creating a composite inner logger which calls
// both loggers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to reference another ticket somewhere for the TODO.

@nblumhardt
Copy link
Contributor

Thanks for the loop-in guys. I had a quick run through it (sunny Saturday morning here, so on my way out :-)) and everything looks fine. Added what comments I could.

One thing I'd give serious thought to - when the buffer in BackgroundSink is full, dropping events in Emit() rather than blocking might be a better strategy. I know the idea of blocking is to provide some back-pressure, but when work is generated externally to the app this won't result in the incoming requests being throttled - it'll more likely eat RAM quickly as threads back up blocked on the Add() call.

Given events are already going to be dropped at shut-down if they can't be flushed within 5 seconds, dropping them proactively when the buffer fills up seems reasonable. It may not always make a difference, but seems like it might help save an app that's under heavy load (or faulty I/O) once in a while.

I had a shot at implementing this strategy here. Let me know if I'm off the mark.

Have a great weekend,
Nick

@victorhurdugaci victorhurdugaci force-pushed the victorhu/azure-logger branch from 5d10260 to b7bcb77 Compare July 29, 2016 22:56
@victorhurdugaci
Copy link
Contributor Author

victorhurdugaci commented Jul 29, 2016

@nblumhardt thanks for taking a look!

@victorhurdugaci
Copy link
Contributor Author

Merging this as it is - it works. Opened a few bugs that we'll address but I don't have time to do it now. I can do it when I return form vacation.

Here are the issues:

cc @muratg

@victorhurdugaci victorhurdugaci merged commit b7bcb77 into dev Jul 29, 2016
@victorhurdugaci victorhurdugaci deleted the victorhu/azure-logger branch July 29, 2016 23:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants