Skip to content

Log to Redis with NLog - .NET 4+ & .NET Standard support

License

Notifications You must be signed in to change notification settings

joshua5822/NLog.Targets.Redis

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build status NuGet

NLog.Targets.Redis

This project provides a custom target for the NLog framework to allow a user to send log messages to a Redis server. The target supports sending log messages to a Redis list or to a pub/sub channel.

Installation

NLog.Targets.Redis is available as a NuGet Package. Type the following command into the Nuget Package Manager Console window to install it:

Install-Package NLog.Targets.Redis

Usage

The <target /> configuration section contains five required fields and one optional field.

  • host (required): The host name or IP Address of the Redis server.
  • port (required): The port the Redis server is listening on.
  • key (required): The key that should be used to identify the Redis list or the pub/sub channel to which the log messages are being delivered.
  • dataType (optional): The Redis data type that should be used to store the log messages. This can be either list or channel, defaults to list.
  • layout (required): The layout that defines the format of the message to be sent to the Redis target.
  • db (optional): The Redis database id to store the log messages in, if the Redis database type list is chosen.

Config File

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true">
  <extensions>
    <add assembly="NLog.Targets.Redis" />
  </extensions>
  <targets>
    <target xsi:type="Redis" name="redis" host="127.0.0.1" port="3679" db="0" 
            key="logKey" dataType="list" 
            layout="${date:format=yyyyMMddHHmmss} ${uppercase:${level}} ${message}" />
  </targets>
  <rules>
    <logger name="*" minlevel="Info" writeTo="redis" />
  </rules>
</nlog>

Notes

This is a fork of https://github.com/richclement/NLog.Redis

About

Log to Redis with NLog - .NET 4+ & .NET Standard support

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%