NLog 5.0 introduces new fluent LogEventBuilder
that can be activated with one of these extensions methods for ILogger
:
ForLogEvent
- Builds base LogEventForTraceEvent
- Builds LogEvent with Trace-LogLevelForDebugEvent
- Builds LogEvent with Debug-LogLevelForInfoEvent
- Builds LogEvent with Info-LogLevelForWarnEvent
- Builds LogEvent with Warn-LogLevelForErrorEvent
- Builds LogEvent with Error-LogLevelForFatalEvent
- Builds LogEvent with Fatal-LogLevelForExceptionEvent
- Builds LogEvent with Exception and Error-LogLevelTo complete the fluent builder then call Log()
to capture available callsite information with help from Caller Member Attributes, and then writes the actual LogEvent to any configured NLog targets.
Replaces the old Fluent-namespace and also reduces memory-allocation when LogLevel not enabled.
_logger.ForInfoEvent() .Message("This is a fluent message {0}.", "test") .Property("PropertyName", "PropertyValue") .Log();Writing Exception Message.
try { string text = File.ReadAllText(path); } catch (Exception ex) { _logger.ForExceptionEvent(ex) .Message("Error reading file '{0}'.", path) .Property("Test", "InfoWrite") .Log(); }
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4