Coder Social home page Coder Social logo

Comments (11)

urielha avatar urielha commented on August 30, 2024

Very weird, what you're saying is that the message is getting into Elastic but without any custom values?
Do you see any error message or any other indication?

Because I have added a specific test for custom values and I won't submit this version if the test wasn't pass...

I hope I could test this soon with your config.
Please update if you have more insights.

Regards

from log4stash.

urielha avatar urielha commented on August 30, 2024

I can't repro this on my local machine.
Do you still get the count: 0 in you json or you get something else now?

Please check again that you are using the correct version and see if you can find any error message.

from log4stash.

jonhb avatar jonhb commented on August 30, 2024

I can't get custom properties to work either. I set them with GlobalContext.Properties["Guid"] and use %property{Guid} to access them. This works fine in fileappender but not in ElasticSearchAppender.

I get this in ES: "Guid": {}

Do I have to set something up in the config for these custom properties?
All I have is this:

    <appender name="ElasticSearchAppender" type="log4stash.ElasticSearchAppender, log4stash">
      <Server>localhost</Server>
      <Port>9200</Port>
      <IndexName>logstash-%{+yyyyMM}</IndexName>
      <IndexType>log</IndexType>
      <IndexAsync>true</IndexAsync>
    </appender>

from log4stash.

urielha avatar urielha commented on August 30, 2024

Hi @jonhb and @Dima234 ,
Please try this pre release:
https://www.nuget.org/packages/log4stash/2.0.2-pre

Let me know if it fixed your issue.
Thanks

from log4stash.

jonhb avatar jonhb commented on August 30, 2024

Hi,

I still can't get it to work.

from log4stash.

urielha avatar urielha commented on August 30, 2024

emmm... let's try another thing,
try to put:

  <FixedFields>Partial</FixedFields>

inside your configuration file.
(so it will be:

    <appender name="ElasticSearchAppender" type="log4stash.ElasticSearchAppender, log4stash">
        <Server>localhost</Server>
        <Port>9200</Port>
      <IndexName>logstash-%{+yyyyMM}</IndexName>
      <IndexType>log</IndexType>
      <IndexAsync>true</IndexAsync>

      <FixedFields>Partial</FixedFields>

    </appender>

And furthermore, I noticed that you said you

use %property{Guid} to access them

Where do you use it?

Hope the FixedFields will make it work.

Cheers

from log4stash.

jonhb avatar jonhb commented on August 30, 2024

Hi,

I use it where I define the output pattern for the RollingFileAppender (and also where i define parameters for the SQL server appender):

`

`

This outputs the Guid correctly in the file. In the code I set the Guid through a provider class where I have overridden the ToString method to return the Guid variable.
This is only initialized once:
log4net.GlobalContext.Properties["Guid"] = new GuidProvider();
and then this returns the dynamic Guid:
public class GuidProvider { public override string ToString() { return Guid; } }

The FixedFields does not help anything unfortunatly.

from log4stash.

urielha avatar urielha commented on August 30, 2024

Thanks, I'm pretty sure I found the problem.

Will update you soon with new version.

Note that your problem is different from the author of this thread that is why I got a bit confused at first.

from log4stash.

urielha avatar urielha commented on August 30, 2024

Forgot to ask, Is there a reason you don't call toString inline?
like this:

log4net.GlobalContext.Properties["Guid"] = new GuidProvider().toString();

from log4stash.

jonhb avatar jonhb commented on August 30, 2024

I don't think that will work.

from log4stash.

urielha avatar urielha commented on August 30, 2024

Please use this version

https://www.nuget.org/packages/log4stash/2.0.2-b

@jonhb, Add this to your configuration :

<ElasticFilters>

  <Convert>
    <ToString>Guid</ToString>
  </Convert>

</ElasticFilters>

This will cause calling the ToString() function before indexing into ElasticSearch.

@Dima234, Add this to your configuration:

<ElasticFilters>

 <Convert>
    <ToString>UserName</ToString>
    <ToArray>
      <SourceKey>UserName</SourceKey>
    </ToArray>
  </Convert>

</ElasticFilters>

This will cause calling ToString() of the stack object and then convert the values to array.

If you both already have ElasticFilters just add the Convert into it.
And please open new issue if the problem still occurs.

All the best,
Uriel

from log4stash.

Related Issues (20)

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.