-
Notifications
You must be signed in to change notification settings - Fork 13
Changing config on the fly
Sealog was designed to be as stateless as possible: There is no initialization step, the Sealog is immediately ready for logging right after the importing its lib path. If you want to refine your logger's configuration, you simply need to create a new config and call 'SetConfig' func. The number of such reconfigurations is unlimited.
We have a test, that performs long-time config switching in 1000 multiple goroutines that log messages and switch config after each message.
It is located here: sealog/test/stressconfig
The short answer is simple: call SetConfig with a new config at any moment of time. But the main thing here is to provide such functionality to your application users. For example, if you would like to change logging configuration of your server on-the-fly without restarting it, you need to create some kind of web-interface with a config text box and a 'submit' button that would consequently call 'log.ConfigFromBytes(...)' and 'log.SetConfig'. If the ConfigFromBytes returned an error, like config syntax error, you should create a corresponding error web-page response.
Another option is to check whether the config file changed, and if so, create a config from new file bytes and call 'SetConfig' if new config doesn't contain any errors. We are going to provide such config update checker as a helper utility later.