Allow logging to be controlled through `config` command
As a continuation of #852, allow changing the default sizes and number of files through configuration settings in choco. This was pushed as configurations is not available when setting up logging, so they would need to be adjusted as soon as the configuration is available.
This was originally requested by @DarwinJS
I'm assuming you thinking the config would be set via the chocolatey.config or 'choco config'. Is there any specific format with in the file? It would seem the only attribute we are talking about is MBs per file and number of files, correct?
@criter That sounds about right.
Looking into this further, we have a chicken and egg problem. The log is configured before the SimpleInjectorContainer is configured.
Log4NetAppenderConfiguration.configure(loggingLocation);
Bootstrap.initialize();
Bootstrap.startup();
var license = License.validate_license();
var container = SimpleInjectorContainer.Container;
var config = container.GetInstance<ChocolateyConfiguration>();
So there seems to be a few options.
- Move the container creation above the log, seems like it would be a problem since there are likely constructors in there that might need to log.
- When configuring the log, read the config file directly without the ChocolateyConfiguration class, not good since repeating code.
- Instantiate the ChocolateyConfigSettingsService without using the container, then this would leave 2 different ChocolateyConfigSettngsService objects.
Likely some others that I'm not thinking about...
Thoughts?
@criter that's why I moved this out to its own issue, you are touching on what I was seeing and I didn't have a way to deal with it set up just yet. Definitely something to revisit.
:-) Just wanted to make sure I didn't reinvent the wheel if you already had an idea. Let me think about it and see what might make sense and run it by you.
I believe logging configuration can be adjusted at any time.
So it may just be an additional call or set of calls to make the log file size adjustments, etc.
~~Related to #1453~~ (turned out to be invalid)
@mrhockeymonkey I think you might be interested in watching this issue.