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

Custom log4net values get submitted as { "Count": 1 } #4

Closed
urielha opened this issue Apr 12, 2016 · 3 comments
Closed

Custom log4net values get submitted as { "Count": 1 } #4

urielha opened this issue Apr 12, 2016 · 3 comments
Assignees
Labels

Comments

@urielha
Copy link
Owner

urielha commented Apr 12, 2016

From @Dima234 on February 8, 2016 23:15

We log custom property values using log4net with this code:
LogicalThreadContext.Stacks["UserName"].Push("jsmith")

Elasticsearch receives this as

"UserName": {
  "Count": 1
},

expected is

"UserName": "jsmith",

For the reference, correct value ('jsmith' in the example above) gets logged by RollingFileAppender, so it looks like something in log4stash causing this issue. We use latest (1.1.1) log4stash version with MS webapi project targeting .NET 4.6. Our appender config looks like this:


<appender name="ElasticSearchAppender" type="log4net.ElasticSearch.ElasticSearchAppender, log4stash">
    <layout type="log4net.Layout.PatternLayout,log4net">
        <param name="ConversionPattern" value="%utcdate{ABSOLUTE} %-5level %logger - %message%newline" />
    </layout>
    <filter type="log4net.Filter.LevelRangeFilter">
        <levelMin value="WARN" />
        <levelMax value="FATAL" />
    </filter>
    <Server>localhost</Server>
    <Port>9200</Port>
    <IndexName>log_%{+yyyy-MM-dd}</IndexName>
    <IndexType>LogEvent</IndexType>
    <Bulksize>2000</Bulksize>
    <BulkIdleTimeout>10000</BulkIdleTimeout>
    <IndexAsync>True</IndexAsync>
    <FixedFields>772</FixedFields>
    <SerializeObjects>false</SerializeObjects>
    <ElasticFilters>
        <kv>
            <SourceKey>Message</SourceKey>
            <ValueSplit>|</ValueSplit>
            <FieldSplit> ,</FieldSplit>
        </kv>
    </ElasticFilters>
</appender>

Copied from original issue: urielha/log4stash-old#14

@urielha urielha self-assigned this Apr 12, 2016
@urielha urielha added the bug label Apr 12, 2016
@urielha
Copy link
Owner Author

urielha commented Apr 12, 2016

Hi @Dima234 ,
I managed to repro this, the problem occurred after the change on pr #10 .
I will try to figure out a solution which is not collided.

In the meantime I can give you two suggestions:

  • Do you have to use LogicalThreadContext.Stacks? why not use LogicalThreadContext.Properties? this should work fine.
  • You can downgrade to the previous version (log4stash 1.1.0 nuget) of log4stash

I will update when I come up with solution.
Thanks!

@urielha
Copy link
Owner Author

urielha commented Apr 12, 2016

2e14bf7

@urielha
Copy link
Owner Author

urielha commented May 18, 2016

Resolved.
Will release new version soon.

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

No branches or pull requests

1 participant