Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions docs/sources/logging/index.md

This file was deleted.

44 changes: 0 additions & 44 deletions docs/sources/logging/nlog.md

This file was deleted.

51 changes: 2 additions & 49 deletions docs/sources/logging/splat.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,7 @@
# Logging

ReactiveUI comes with its own logging framework which can be used to debug
your applications as well as ReactiveUI itself. You may ask yourself,
"Seriously, another logging framework?". The reason RxUI does this itself is
for portability - none of the common popular logging frameworks support all of
the platforms that ReactiveUI supports, and many are server-oriented
frameworks and ill-suited for simple mobile app logging.

### this.Log() and IEnableLogger

ReactiveUI's logger works a bit differently than other frameworks - its
design is inspired by Rails 'logger'. To use it, make your class implement the
`IEnableLogger` interface:

```cs
public class MyClass : IEnableLogger
{
// IEnableLogger doesn't actually require anything of us
}
```

Now, you can call the `Log` method on your class. Because of how extension
methods work, you must prepend `this` to it:

```cs
this.Log().Info("Downloaded {0} tweets", tweets.Count);
```

There are **five** levels of logging, `Debug`, `Info`, `Warn`, `Error`, and
`Fatal`. Additionally, there are special methods to log exceptions - for
example, `this.Log().InfoException(ex, "Failed to post the message")`.

This trick doesn't work for static methods though, you have to settle for an
alternate method, `LogHost.Default.Info(...)`.
ReactiveUI uses [Splat](https://github.com/paulcbetts/splat) for logging and
adds some useful helpers for debugging observables to it.

### Debugging Observables

Expand All @@ -56,19 +25,3 @@ to the Logger. For example:
var userAvatar = await FetchUserAvatar()
.LoggedCatch(this, Observable.Return(default(Avatar)));
```

### Configuring the logger

To configure the logger, register an implementation of `ILogger` (there are
several built-in ones, such as `DebugLogger`). Here's an example where we use
a built-in logger, but a custom log level:

```cs
// I only want to hear about errors
var logger = new DebugLogger() { LogLevel = LogLevel.Error };
Locator.CurrentMutable.RegisterConstant(logger, typeof(ILogger));
```

If you really need to control how things are logged, you can implement
`IFullLogger`, which will allow you to control every logging overload.