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" }); }
private void LoadFile() { try { _stopWords.Add("EN", new HashSet <string>(File.ReadLines(@"nouns.txt"), StringComparer.OrdinalIgnoreCase)); _stopWords.Add("NL", new HashSet <string>(File.ReadLines(@"nounlist-NL.txt"), StringComparer.OrdinalIgnoreCase)); } catch (Exception e) { _logger.LogError(e.Message); } }
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { Button button = e.Source as Button; if (button == null) { return; } if (button.Name == nameof(btnTest)) { Logger.LogInformation("Information"); try { int i = 0; int j = 1 / i; } catch (Exception ex) { Logger.LogError(ex, "Error Information"); } } }