Skip to content
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

Custom logging instead of NLog-based one (OSOE-402) #206

Open
Piedone opened this issue Oct 17, 2022 · 6 comments
Open

Custom logging instead of NLog-based one (OSOE-402) #206

Piedone opened this issue Oct 17, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@Piedone
Copy link
Member

Piedone commented Oct 17, 2022

Currently, the UI Testing Toolbox depends on NLog. In OrchardApplicationFactory we configure NLog for logging, and OrchardCoreInstance.GetLogs() we load the log files. Instead, while retaining support for the app under test to use NLog logging for its own reasons, we could have our custom in-memory logger just for testing. That'd collect log messages about errors and warnings, and we'd use that to check for log entries to fail the test.

Decoupling the project from NLog would also prevent issues like this when Orchard updates its NLog version: OrchardCMS/OrchardCore#11194 (comment)

Related: Lombiq/Open-Source-Orchard-Core-Extensions#264 (comment)

Jira issue

@Piedone Piedone added the enhancement New feature or request label Oct 17, 2022
@github-actions github-actions bot changed the title Custom logging instead of NLog-based one Custom logging instead of NLog-based one (OSOE-402) Oct 17, 2022
@rikbosch
Copy link

rikbosch commented Nov 6, 2023

Could something like https://github.com/horsdal/InMemoryLogger/blob/master/src/InMemoryLogger.cs be a solution?

@Piedone
Copy link
Member Author

Piedone commented Nov 6, 2023

Yep, looks suitable. Through InMemoryLogger.RecordedLogs we could also access the log entries.

In any case, the FailureDump should still contain a full log file.

@rikbosch
Copy link

What about using OpenTelemetry for capturing logs / traces and metrics of a specific failed test?

@Piedone
Copy link
Member Author

Piedone commented Nov 15, 2023

That could be useful for tracing tests in general, though well beyond the scope of this issue, which is about substituting the ILogger implementation.

See also OrchardCMS/OrchardCore#12251.

@Piedone
Copy link
Member Author

Piedone commented Jan 10, 2024

Perhaps the best would be to use FakeLogger. Then FakeLogCollector can be used to retrieve the log messages.

@Piedone
Copy link
Member Author

Piedone commented Mar 9, 2024

This would also allow us to better filter log messages. Thus, we wouldn't log ErrorController's exception, to begin with, instead of filtering it out during assertion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants