Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small issue with compact #25

Open
fox-infonote opened this issue Jun 24, 2019 · 1 comment
Open

Small issue with compact #25

fox-infonote opened this issue Jun 24, 2019 · 1 comment

Comments

@fox-infonote
Copy link

Hi, think I have found a small bug with version 2.0

I upgrade and added compact to target setting it to false.

The logs on Slack only showed Process name and PID. Tried removing compact and got the same result.

When I set the compact value to true the layout data appeared with out the Process name and PID.

Had a look at the code and but can't see an obvious cause for this.

My target look like this.

<target xsi:type= "Slack
name="Slack_Warn"
layout="${longdate}|${level:uppercase=true}${Environment} ${logger} ${message} ${exception:format=tostring}"
webHookUrl="https://hooks.slack.com/services/restofurl" compact="true" />

so don't have the fields you show in your example .. is that the issue ?

@TimothyRatliff
Copy link

TimothyRatliff commented Oct 9, 2019

I'm having this same issue (logs on slack only show PID/process name), except I'm configuring the Slack target through code.

            var slackTarget = new SlackTarget
            {
                // Name = "slackTarget",
                Layout = "${message}",
                WebHookUrl = configuration.GetSection("JsonConfigurations").GetValue<String>("webHookUrl"),
                Compact = false,
            };
            config.AddTarget("slack", slackTarget);

Whenever I change Compact to true, the actual message content goes through.

I don't seem to have this issue when using nlog.config to configure the Slack target. Unfortunately, I have to use code to configure the target because I'm passing in variables from appsettings.json. So this isn't a viable work-around for me.

@fox-infonote did you try setting the field names inside your nlog.config? Here's my nlog.config that sends the full message content:

    <target xsi:type="Slack"
            name="slackTarget"
            layout="${message}"
            webHookUrl="url"
            compact="false">

      <field name="Machine Name" layout="${machinename}" />
      <field name="Process Name" layout="${processname}" />
      <field name="Process PID" layout="${processid}" />
      <field name="DateTime" layout="${longdate}" />
    </target>
    
  </targets>

Tagging @eth0izzle in hopes of a response :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants