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

Adding a new logger for tooling console log entries from language workers so that they are always logged as Informational #8435

Merged
merged 4 commits into from
Jun 9, 2022

Conversation

kshyju
Copy link
Member

@kshyju kshyju commented Jun 3, 2022

Adding a new logger for tooling console log entries from language workers so that they are always logged as Informational irrespective of Host category level present in HOST.JSON

The dotnet language worker has a startup hook which emits some meta information about the language worker process (ex: processId). This information is emitted via standard output using Console.WriteLine API. The Host reads this std output stream and log that information using ILogger. We have a console logger which will print this in the console when in development mode, which IDE/Debuggers may read (the processId) so that they can attach to the process.

When the host.JSON of dotnet isolated function app specify "Error" as the minimum log level for "Host" category, this information is not surfaced to console as ILogger will discard any log message with level below "Error". The tooling console log messages are sent as "Information" level one and thus being dropped.

The fix here in this PR is having a separate ILogger for the tooling related log messages coming from worker. We identify the tooling related messages by checking the existence of a special prefix(azfuncjsonlog:), and if detected, we will use the new logger for logging that message. This log level of this special logger is set to Informational in code (Customers/Users are not supposed to change this), so that the log level value of "Host" category is not impacting this log entries.

Relevant issue: Azure/azure-functions-dotnet-worker#900

…via standard output (Console.WriteLine) with Information level as the logging level so that the logging level set for Host is not affecting these log entries as they are being used by debuggers/IDEs
@kshyju kshyju marked this pull request as draft June 3, 2022 20:29
@kshyju kshyju marked this pull request as ready for review June 3, 2022 21:26
@kshyju kshyju requested a review from pragnagopa June 3, 2022 21:35
}

internal WorkerConsoleLogService(ILogger logger, IWorkerConsoleLogSource consoleLogSource)
internal WorkerConsoleLogService(ILogger logger, Lazy<ILogger> toolingConsoleJsonLoggerLazy, IWorkerConsoleLogSource consoleLogSource)
Copy link
Member Author

Choose a reason for hiding this comment

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

This constructor is being used by UTs to inject test version of dependencies.

Copy link
Member

@liliankasem liliankasem left a comment

Choose a reason for hiding this comment

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

lgtm, only comment I have is around naming (see above comment)

@@ -49,7 +49,7 @@ public ILogger CreateLogger(string categoryName)

private bool IsUserLogCategory(string categoryName)
{
return LogCategories.IsFunctionUserCategory(categoryName) || categoryName.Equals(WorkerConstants.FunctionConsoleLogCategoryName, StringComparison.OrdinalIgnoreCase);
return LogCategories.IsFunctionUserCategory(categoryName) || categoryName.Equals(WorkerConstants.ConsoleLogCategoryName, StringComparison.OrdinalIgnoreCase);
Copy link
Member Author

Choose a reason for hiding this comment

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

Reflecting the change of renaming the constant to remove the "Function" prefix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants