Exemple #1
0
        public IEnumerable <string> Get()
        {
            var exception = new Exception();

            _logger.LogTrace("Log trace");
            _logger.LogDebug("Log debug");
            _logger.LogInformation("Log information");
            _logger.LogWarning("Log warning");
            _logger.LogError(exception.HResult, exception, string.Empty);    // this one will not be logged
            _logger.LogCritical(exception.HResult, exception, string.Empty); // this one will not be logged as well

            // you have to specif not empty (might be whitespaced) message when logging exception
            _logger.LogError(exception.HResult, exception, " ");
            _logger.LogCritical(exception.HResult, exception, " ");
//
            // as opposite to the original behavior of NLog
            // NlogLogger.Error(exception);

            return(new string[] { "value1", "value2" });
        }