using NLog; var logger = LogManager.GetCurrentClassLogger(); try { // some code that might throw an exception } catch (Exception ex) { logger.Error(ex, "An error occurred"); }In this example, we first obtain an instance of the `Logger` class using the `GetCurrentClassLogger()` method of the `LogManager` class. Then we wrap some code in a `try`/`catch` block, and log any exception that occurred using the `Error()` method of the logger. The second parameter to the `Error()` method is an optional message that provides additional context for the error. In this case, we just log a generic message, but you could tailor it to the specific error condition. The NLog library is available as a NuGet package, which you can add to your project using the NuGet Package Manager in Visual Studio.