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

Log4Stash logging metadata info by itself #79

Open
Gprsk opened this issue Jun 1, 2021 · 2 comments
Open

Log4Stash logging metadata info by itself #79

Gprsk opened this issue Jun 1, 2021 · 2 comments

Comments

@Gprsk
Copy link

Gprsk commented Jun 1, 2021

Hello!

I've started to use log4stash in our application to send log information to a AWS-Auth elastic search, but I noticed it started to log information by itself.

It logs so much info, following the correct log over console(the ones I want) is very difficult.

My log4net config file (partial and with sensitive info hidden):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>

  <log4net debug="false">

    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
      </layout>
    </appender>

    <appender name="ElasticSearchAppender" type="log4stash.ElasticSearchAppender, log4stash">
      <Server>whatever</Server>
      <Port>80</Port>
      <IndexName>happy-index</IndexName>
      <IndexType>logEvent</IndexType>
      <BulkSize>100</BulkSize>
      <BulkIdleTimeout>1000</BulkIdleTimeout>
      <IndexAsync>False</IndexAsync>
      <DropEventsOverBulkLimit>False</DropEventsOverBulkLimit>

      <SerializeObjects>True</SerializeObjects>

      <ElasticSearchTimeout>10000</ElasticSearchTimeout>

      <FixedFields>Partial</FixedFields>

      <Ssl>false</Ssl>
      
      <AuthenticationMethod>
        <!--For AWS ElasticSearch service -->
        <Aws>
          <Aws4SignerSecretKey>abc</Aws4SignerSecretKey>
          <Aws4SignerAccessKey>123</Aws4SignerAccessKey>
          <Aws4SignerRegion>somewhere</Aws4SignerRegion>
        </Aws>
      </AuthenticationMethod>
    </appender>

    <root>
      <level value="INFO"/>
      <appender-ref ref="ElasticSearchAppender"/>
      <appender-ref ref="ConsoleAppender"/>      
    </root>
  </log4net>
</configuration>

And then, during my logging process, im greeted (in the console) with A LOT of those:

CanonicalRequest:
POST
/_bulk

content-type:application/json
host:whatever
x-amz-content-sha256:longStringHere
x-amz-date:20210601T212541Z

content-type;host;x-amz-content-sha256;x-amz-date
longStringHereToo

StringToSign:
AWS4-HMAC-SHA256
20210601T212541Z
20210601/us-east-1/es/aws4_request
anotherLongString

Signature:
numbersAndLetters

Authorization:
AWS4-HMAC-SHA256 Credential=Weeeeeee/20210601/us-east-1/es/aws4_request, SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date, Signature=veryLongStringWithSignature

When I change the root level value to WARN or higher, those logs dissapear. However, my guess is they dont show up because nothing is happening (no logs are being logged)
By checking the Aws4SignerForAuthorizationHeader class, I found many Console.WriteLine statements.

Is there any way to disable those internal loggings with a flag or something? Or just log errors?

Im not sure how I can create a PR with a quick fix for this scenario.

@eran-gil
Copy link
Collaborator

eran-gil commented Jun 2, 2021

Hey, I looked in the code and found the cause to these logs.
Created a PR (#80) where these logs would be considered 'debug' as they should be.
You're welcome to look and see if it fits your needs.
@urielha If you have the time please look at the code and see if it makes sense, and then we can deploy a new version.

@Gprsk
Copy link
Author

Gprsk commented Jun 25, 2021

Waiting for the new release!

Thank you for helping us!

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