Full AWS Practitioner Certification Question

In ASP.NET, how do you write a message to the application diagnostics log that only shows up when the user has enabled warning level messages?