I have a very old C#
based web application in Visual Studio 2019
.
There are hundreds of files in the solution with probably thousands of lines for logging.
We have recently realized that we don't need this logging any more and so I need to remove these statements from the code.
So my question - Is there any way to remove these logging statements from the code in one shot using Find/Replace
or any other clean up tool?
The statements look like this -
_logger.LogInformation("Something happened here");
CodePudding user response:
You can use (a limited form of) regular expressions when searching and replacing in Visual Studio.
Go to Edit | Find and Replace | Replace in Files
to open the dialog, and then select Use regular expressions.
Then your target text should be something like:
(^|\s)*_logger\.LogInformation\(.*\);
And the replacement would be an empty string. Click Replace All and it will probably replace most of them. However, this sort of thing can be fraught with peril, so you should check carefully what changes it makes!