Repository navigation
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.
Add missing format exception catcher to Akka.TestKit.Xunit that was added to Akka.TestKit.Xunit2
| /// <returns>TBD</returns> | ||
| protected override bool Receive(object message) | ||
| { | ||
| if(message is InitializeLogger) |
There was a problem hiding this comment.
Change if...then...else structure to switch
| 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.
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.
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.
New HOCON setting to customize the standard out logger
| /// <summary> | ||
| /// The off log level. | ||
| /// </summary> | ||
| OffLevel = int.MaxValue |
There was a problem hiding this comment.
Added OffLevel to LogLevel enum, this would act as a marker for the off state
There was a problem hiding this comment.
I'd revert this change - it's a major part of the public API and will require an update to all downstream loggers probably.
|
|
||
| namespace Akka.Event | ||
| { | ||
| public abstract class MinimalLogger : MinimalActorRef |
There was a problem hiding this comment.
MinimalLogger is the abstract base class for implementing minimal loggers.
There was a problem hiding this comment.
In a separate PR, we should add some documentation for this
Aaronontheweb
left a comment
There was a problem hiding this comment.
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()); |
| } | ||
|
|
||
| [Fact(DisplayName = "StandardOutLogger should not be called on shutdown when stdout-loglevel is set to OFF")] | ||
| public async Task StandardOutLoggerShouldNotBeCalled() |
| 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.
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( |
| /// 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 |
| /// <summary> | ||
| /// The off log level. | ||
| /// </summary> | ||
| OffLevel = int.MaxValue |
There was a problem hiding this comment.
I'd revert this change - it's a major part of the public API and will require an update to all downstream loggers probably.
Aaronontheweb
left a comment
There was a problem hiding this comment.
Some more cleanup needed to undo the LogLevel.Off change
| case LogLevel.ErrorLevel: | ||
| return Error; | ||
| case OffLogLevel: | ||
| return Off; |
| return LogLevel.ErrorLevel; | ||
| case Off: | ||
| return OffLogLevel; | ||
| return (LogLevel) int.MaxValue; |
There was a problem hiding this comment.
Should add back previous call
…ufus/akka.net into Add_new_StandardOutLogger_features
| /// </summary> | ||
| /// <param name="logEvent">The event to print</param> | ||
| public static void PrintLogEvent(LogEvent logEvent) | ||
| internal static void PrintLogEvent(LogEvent logEvent) |
|
|
||
| namespace Akka.Event | ||
| { | ||
| public abstract class MinimalLogger : MinimalActorRef |
There was a problem hiding this comment.
In a separate PR, we should add some documentation for this
|
|
|
Done, documentation added. |
|
Should be ready for review now |
| `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.
Probably need to do more showing rather than telling here, but this is good for now
| { | ||
| var logLevel = Logging.LogLevelFor(config.StdoutLogLevel); | ||
| SubscribeLogLevelAndAbove(logLevel, Logging.StandardOutLogger); | ||
| SubscribeLogLevelAndAbove(logLevel, config.StdoutLogger); |
There was a problem hiding this comment.
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.
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.
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.
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