Skip to content

Commit

Permalink
Merge pull request #15 from dojo90/14-Update-Readme
Browse files Browse the repository at this point in the history
14 update readme
  • Loading branch information
djonasdev committed Feb 10, 2020
2 parents 101374f + 9200997 commit 4adbf27
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 11 deletions.
69 changes: 58 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
[3]: https://github.com/yarseyah/sentinel#nlogs-nlogviewer-target-configuration

[p1]: doc/images/control.png "NLogViewer"
[p2]: doc/images/preview.gif "NLogViewer"
[p3]: doc/images/control2.png "NLogViewer"
[p2]: doc/images/live.gif "NLogViewer"
[p3]: doc/images/colors.png "NLogViewer"

[nuget]: https://nuget.org/packages/Sentinel.NlogViewer/

Expand All @@ -20,16 +20,9 @@ NlogViewer

NlogViewer is a ui control library to visualize NLog logs in your personal application. It is mainly based on [Sentinel][1] and its controls.

![NLogViewer][p2]

Actually it contains the following controls:

- `NLogViewer`

Visual Studio
supported Frameworks: `.NETCoreApp v3.0`, `.NETCoreApp v3.1`, `.NET Framework 4.6.1`

![NLogViewer][p1]
![NLogViewer][p3]
![NLogViewer][p2]

## Quick Start

Expand Down Expand Up @@ -72,6 +65,60 @@ If you want to customize the `loggingPattern` and `LogLevel`, add the following
</nlog>
```

## Customize

### Colors

Customize `foreground` or `background` of every `logLevel`

![NLogViewer][p3]

### Multi targeting

Use more than one instance of `NLogViewer` to match different `rules`.

Create 2 `targets` with their own `rules`.

```xml
<targets async="true">
<target xsi:type="CacheTarget" name="target1"/>
<target xsi:type="CacheTarget" name="target2"/>
</targets>

<rules>
<logger name="*" writeTo="target1" maxlevel="Info"/>
<logger name="*" writeTo="target2" minlevel="Warn"/>
</rules>
```

Set `TargetName` property to link them.

```xml
<dj:NLogViewer TargetName="target1"/>
<dj:NLogViewer TargetName="target2"/>
```

### Format output (ILogEventInfoResolver)

To format the output of a `LogEventInfo`, implement a new instance of `ILogEventInfoResolver` and bind it to the `Resolver` you want to customize:

```csharp
/// <summary>
/// Reformat the DateTime
/// </summary>
public class FooTimeStampResolver : ILogEventInfoResolver
{
public string Resolve(LogEventInfo logEventInfo)
{
return logEventInfo.TimeStamp.ToUniversalTime().ToString();
}
}
```

```csharp
NLogViewer1.TimeStampResolver = new FooTimeStampResolver();
```

## Why CacheTarget?

There is already a `NLogViewerTarget`, which is used for [Sentinel][1]. See [here][3]
Expand Down
Binary file added doc/images/colors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed doc/images/control.png
Binary file not shown.
Binary file removed doc/images/control2.png
Binary file not shown.
Binary file added doc/images/live.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed doc/images/preview.gif
Binary file not shown.
3 changes: 3 additions & 0 deletions src/NLogViewer.TestApp/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ public MainWindow()
}
}

/// <summary>
/// Reformat the DateTime
/// </summary>
public class FooTimeStampResolver : ILogEventInfoResolver
{
public string Resolve(LogEventInfo logEventInfo)
Expand Down

0 comments on commit 4adbf27

Please sign in to comment.