Giter Club home page Giter Club logo

nlog.targets.aliyun's Introduction

NLog Target for Aliyun Log Service

A .NET Core NLog target to send log message to Aliyun Log Service.

Install via NuGet

Install-Package NLog.Targets.Aliyun

Steps to Configure

  1. Create a Log Service project and logstore

  2. Enable RAM access control and create an AccessKey

  3. Add NLog.Targets.Aliyun as an extension to your nlog.config

  4. Configure endpoint, project, accessKeyId and accessKey in the nlog.config

  5. Specify the logstore you want the log post to

    e.g., set logStore="${lowercase:${aspnet-environment}}", the log will send to development, staging or production logstore depends on the environment, some initialization logs will be dropped as environment not set yet

Supported Configuration

  • name - Specify a name, but make sure you use the same name in logger rules section
  • endpoint - You can find it in the home screnn of your log service project. Use external endpoint if your application is not deployed within Aliyun
  • project - The log service project name you specified
  • accessKeyId - The RAM access key id
  • accessKey - The RAM access key
  • logStore - Support layout rendering, the log service log store name you specified
  • source - Support layout rendering, leave as empty send nothing to server while remove this attribute will send the IP address the application are running
  • topic - Support layout rendering, leave as empty send nothing to server while remove this attribute will send the logger name
  • layout - The message layout, this property will be ignored when context properties is set

Configuration Examples

  • Add NLog.Targets.Aliyun Extension
        <add assembly="NLog.Targets.Aliyun"/>
  • Add Aliyun Target
        <target xsi:type="Aliyun" name="aliyun"
                endpoint="<your-endpoint>"
                project="<your-project-name>"
                accessKeyId="<your-access-key-id>"
                accessKey="<your-access-key>"
                logStore="<your-log-store-name>">
            <contextProperty name="time" layout="${longdate}" />
            <contextProperty name="level" layout="${level}" />
            <contextProperty name="sequence" layout="${sequenceId}" />
            <contextProperty name="message" layout="${message}" />
            <contextProperty name="exception" layout="${exception:format=ToString,StackTrace}" includeEmptyValue="false" />
        </target>
  • Add Logger Rules
        <logger name="*" minlevel="Debug" writeTo="aliyun" />

See a full example in the demo project.

nlog.targets.aliyun's People

Contributors

jerryjiang avatar jerry-aug avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.