-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Make sure stdout-loglevel setting is honored through the whole actor system lifecycle #5251
Make sure stdout-loglevel setting is honored through the whole actor system lifecycle #5251
Conversation
{ | ||
try | ||
{ | ||
_output.WriteLine(e.ToString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missing format exception catcher to Akka.TestKit.Xunit that was added to Akka.TestKit.Xunit2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -30,57 +30,65 @@ public class TestEventListener : DefaultLogger | |||
/// <returns>TBD</returns> | |||
protected override bool Receive(object message) | |||
{ | |||
if(message is InitializeLogger) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change if...then...else structure to switch
@@ -109,6 +110,31 @@ public Settings(ActorSystem system, Config config, ActorSystemSetup setup) | |||
|
|||
LogLevel = Config.GetString("akka.loglevel", null); | |||
StdoutLogLevel = Config.GetString("akka.stdout-loglevel", null); | |||
|
|||
var stdoutClassName = Config.GetString("akka.stdout-logger-class", null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the hard-wired StandardOutLogger instance from the Logging class to the Settings class.
Default StandardOutLogger is now customizable through the HOCON configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this was @zbynek001's suggestion in one of those threads - we should document this inside https://getakka.net/articles/utilities/logging.html#standard-loggers
|
||
# Fully qualified class name (FQCN) of the very basic logger used on startup and shutdown. | ||
# You can substitute the logger by supplying an FQCN to a custom class that implements Akka.Event.MinimumLogger | ||
stdout-logger-class = "Akka.Event.StandardOutLogger" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New HOCON setting to customize the standard out logger
src/core/Akka/Event/LogLevel.cs
Outdated
/// <summary> | ||
/// The off log level. | ||
/// </summary> | ||
OffLevel = int.MaxValue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added OffLevel to LogLevel enum, this would act as a marker for the off state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd revert this change - it's a major part of the public API and will require an update to all downstream loggers probably.
@@ -13,6 +13,38 @@ | |||
|
|||
namespace Akka.Event | |||
{ | |||
public abstract class MinimalLogger : MinimalActorRef |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MinimalLogger is the abstract base class for implementing minimal loggers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a separate PR, we should add some documentation for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably leave the LogLevel
enum alone - as that's a pretty viral change without much benefit, but other than that this PR looks good. Need to add some documentation as well.
{ | ||
try | ||
{ | ||
_output.WriteLine(e.ToString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
} | ||
|
||
[Fact(DisplayName = "StandardOutLogger should not be called on shutdown when stdout-loglevel is set to OFF")] | ||
public async Task StandardOutLoggerShouldNotBeCalled() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -109,6 +110,31 @@ public Settings(ActorSystem system, Config config, ActorSystemSetup setup) | |||
|
|||
LogLevel = Config.GetString("akka.loglevel", null); | |||
StdoutLogLevel = Config.GetString("akka.stdout-loglevel", null); | |||
|
|||
var stdoutClassName = Config.GetString("akka.stdout-logger-class", null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this was @zbynek001's suggestion in one of those threads - we should document this inside https://getakka.net/articles/utilities/logging.html#standard-loggers
} | ||
catch (MissingMethodException) | ||
{ | ||
throw new MissingMethodException( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -12,7 +12,7 @@ namespace Akka.Event | |||
/// <summary> | |||
/// This class represents a message used to notify subscribers that a logger has been initialized. | |||
/// </summary> | |||
public class LoggerInitialized : INoSerializationVerificationNeeded | |||
public class LoggerInitialized : INoSerializationVerificationNeeded, IDeadLetterSuppression |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
src/core/Akka/Event/LogLevel.cs
Outdated
/// <summary> | ||
/// The off log level. | ||
/// </summary> | ||
OffLevel = int.MaxValue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd revert this change - it's a major part of the public API and will require an update to all downstream loggers probably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more cleanup needed to undo the LogLevel.Off
change
src/core/Akka/Event/Logging.cs
Outdated
@@ -193,8 +187,6 @@ public static string StringFor(this LogLevel logLevel) | |||
return Warning; | |||
case LogLevel.ErrorLevel: | |||
return Error; | |||
case OffLogLevel: | |||
return Off; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add this back
src/core/Akka/Event/Logging.cs
Outdated
@@ -284,7 +276,7 @@ public static LogLevel LogLevelFor(string logLevel) | |||
case Error: | |||
return LogLevel.ErrorLevel; | |||
case Off: | |||
return OffLogLevel; | |||
return (LogLevel) int.MaxValue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add back previous call
…ufus/akka.net into Add_new_StandardOutLogger_features
@@ -107,7 +119,7 @@ protected override void TellInternal(object message, IActorRef sender) | |||
/// Prints a specified event to the console. | |||
/// </summary> | |||
/// <param name="logEvent">The event to print</param> | |||
public static void PrintLogEvent(LogEvent logEvent) | |||
internal static void PrintLogEvent(LogEvent logEvent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -13,6 +13,38 @@ | |||
|
|||
namespace Akka.Event | |||
{ | |||
public abstract class MinimalLogger : MinimalActorRef |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a separate PR, we should add some documentation for this
|
Done, documentation added. |
Should be ready for review now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
`akka.stdout-loglevel` HOCON settings to `OFF` if you do not need these feature in your application. | ||
|
||
### Advanced MinimalLogger Setup | ||
You can also replace `StandardOutLogger` by making your own logger class with an empty constructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably need to do more showing rather than telling here, but this is good for now
@@ -226,7 +226,7 @@ public void StartStdoutLogger(Settings config) | |||
private void SetUpStdoutLogger(Settings config) | |||
{ | |||
var logLevel = Logging.LogLevelFor(config.StdoutLogLevel); | |||
SubscribeLogLevelAndAbove(logLevel, Logging.StandardOutLogger); | |||
SubscribeLogLevelAndAbove(logLevel, config.StdoutLogger); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line change is what PR title says, right?
Before change in this line (229) akka.stdout-loglevel
wasn't honored and now, after this line has changed, it is honored, so off means off even during shutdown, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, when you set stdout-loglevel
to off
, nothing will be outputted by the StandardOutLogger, correct.
/// </summary> | ||
/// <param name="config">The configuration used to configure the <see cref="StandardOutLogger"/>.</param> | ||
/// <param name="config">The configuration used to configure the <see cref="MinimalLogger"/>.</param> | ||
public void StartStdoutLogger(Settings config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I get it right, it's a bit misleading, that if you set your own MinimalLogger then you need to configure it's logging level through akka.stdout-loglevel
not for example akka.minimallogger-loglevel
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StandardOutLogger derives from MinimalLogger, it is the barest minimum logger used to log how the system behave without actual loggers running, ie. a logger to log the loggers themselves, it runs at the very start and the very end of the ActorSystem life cycle. The only thing you can make by inheriting MinimalLogger is a replacement for the StandardOutLogger, thus it will use the same settings as StandardOutLogger.
You would never do this under normal circumstances, it is considered as an advanced configuration/customization
Closes #5246