Let Nlog use Line Notify to post message on your LINE.
Support .NET Core 2.0 and .NET Framework 4.6
- Post message to LINE Notify
- Async to send without missing any log.
- Go to Line Notify, Login in your account
- Go to My Page
- Click Generate token, input a displaed name and select your notification group.
- Copy AsscessToken to NLog target setting.
- Use LINE App, Add Line Notify to your notification group.
<?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.
- Don't forget config extension
<extensions>
<add assembly="NLog.LineNotifyKit" />
</extensions>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();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>Copyright (c) 2018 Crab Lin