Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon What changes were made in MvvmCross 8 regarding logging


What changes were made in MvvmCross 8 regarding logging


In MvvmCross 8, significant changes were made to the logging system. Here are the key changes:

1. Switch to Microsoft.Extensions.Logging: MvvmCross 8 abandoned its custom logging interface (`IMvxLog`) and adopted the `Microsoft.Extensions.Logging` framework. This change provides a stable and widely supported API, allowing for easier integration with various third-party logging providers like Serilog[1][10].

2. Removal of Reflection Dependency: Unlike the previous version, MvvmCross 8 does not directly depend on third-party providers through reflection. Instead, it uses the `ILogger` and `ILoggerFactory` interfaces to manage logging, which can be injected into classes like ViewModels, Services, and Repositories[1].

3. Implementation Requirements: Users must now explicitly implement their own `MvxSetup` derivative and override two logging-related methods: `CreateLogProvider` and `CreateLogFactory`. This is a breaking change from previous versions where default implementations were provided[4][10].

4. Customization with Third-Party Providers: Users can customize logging by installing third-party providers such as Serilog. This involves implementing `CreateLogProvider` and `CreateLogFactory` methods in the `Setup.cs` file to configure Serilog or other providers[1][4].

5. Scoped Logging: The new logging system allows for scoped logging, which automatically associates logs with specific contexts (e.g., a ViewModel). This makes it easier to filter logs based on their source[1].

Overall, these changes aim to provide a more flexible and standardized logging system in MvvmCross 8, aligning with broader .NET ecosystem practices.

Citations:
[1] https://www.mvvmcross.com/documentation/fundamentals/logging-new
[2] https://www.mvvmcross.com/logging
[3] https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/ALTER-MATERIALIZED-VIEW-LOG.html
[4] https://www.mvvmcross.com/documentation/upgrading/upgrade-to-mvvmcross-80
[5] https://www.mvvmcross.com/documentation/fundamentals/viewmodel-lifecycle
[6] https://github.com/MvvmCross/MvvmCross/blob/develop/CHANGELOG.md
[7] https://stackoverflow.com/questions/68075159/mvvm-cross-logging-setup-class
[8] https://github.com/MvvmCross/MvvmCross/issues/1649
[9] https://github.com/MvvmCross/MvvmCross/releases
[10] https://www.mvvmcross.com/mvvmcross-8.0.0-release/