Skip to content

crablin/NLog.LineNotifyKit

Repository files navigation

NLog.LineNotifyKit

NuGet

Overview

Let Nlog use Line Notify to post message on your LINE.

Support .NET Core 2.0 and .NET Framework 4.6

Features

  • Post message to LINE Notify
  • Async to send without missing any log.

Usage

  1. Go to Line Notify, Login in your account
  2. Go to My Page
  3. Click Generate token, input a displaed name and select your notification group.
  4. Copy AsscessToken to NLog target setting.
  5. Use LINE App, Add Line Notify to your notification group.

nlog.config

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <extensions>
    <add assembly="NLog.LineNotifyKit" />
  </extensions>

  <targets>
    <targets>
    <target xsi:type="LineNotify"
            name="Line"
            layout="${message}"
            AccessToken="XXX"/>
  </targets>

  <rules>
    <logger name="*" minlevel="Debug" writeTo="Line" />
  </rules>
</nlog>
  • AccessToken : the token has permission on Line notify post.

Extension Assembly

  • Don't forget config extension
<extensions>
    <add assembly="NLog.LineNotifyKit" />
</extensions>

Async on Console

Avoid post slack api is closed when thread is end. you must be code that.

var logger = _factory.GetCurrentClassLogger();

logger.Info("message");

LineNotifyLogQueue.WaitAsyncCompleted().Wait();

Async Exception on .NET 4.5

If you get this exception message on website:

InvalidOperationException: An asynchronous operation cannot be started at this time.

Refer to MSDN Blog

You must be add aspnet:UseTaskFriendlySynchronizationContext on web.config appSetting

<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    <!-- other values -->
  </appSettings>
</configuration>

License

Copyright (c) 2018 Crab Lin

About

Line notify use NLog target setting

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages