jjchiw / gelf4net

GELF log4net Appender - graylog2
MIT License
63 stars 59 forks source link

100% CPU usage on 3.0.0.16 / GelfHttpAppender 10.0.0.20 #76

Closed thiagoloureiro closed 3 years ago

thiagoloureiro commented 3 years ago

.NET 5 API

After update, today to the latest versions CPU topped up 100% I had to downgrade.

image

jjchiw commented 3 years ago

Hi!

I did some changes because there was an issue when gelf4net couldn't reach graylog server....

Can you post your configuration

https://github.com/jjchiw/gelf4net/issues/75#issuecomment-796313805

Thanks

thiagoloureiro commented 3 years ago

My AsyncGelfHttpAppender:

image

    <appender name="AsyncGelfHttpAppender" type="Gelf4Net.Appender.AsyncGelfHttpAppender, Gelf4Net">
        <url value="server" />
        <!-- Number of log lines to buffer for async send. Defaults to 10-->
        <bufferSize value="20" />
        <!-- Number of tasks to use for the async appender. 0 or fewer indicates one task per processor-->
        <threads value="2" />
        <layout type="Gelf4Net.Layout.GelfLayout, Gelf4Net">
            <param name="AdditionalFields" value="Application:AsyncHttpAppender,version:${version},envName:${cliente}, stringLevel:%level" />
            <param name="Facility" value="Solver-API" />
            <param name="IncludeLocationInformation" value="true" />
            <param name="SendTimeStampAsString" value="false" />
            <!--Sets the full_message and short_message to the specified pattern-->
            <!--<param name="ConversionPattern" value="[%t] %c{1} - %m" />-->
        </layout>
    </appender>
jjchiw commented 3 years ago

Hi,

Can you tell me more about the environment so I can reproduce it. The tests I did was to run the SimpleWebApplication and used NBomber and it didn't peak....

I'll try during the week with the settings

<bufferSize value="20" />
<threads value="2" />

thanks

thiagoloureiro commented 3 years ago

LEt me try with your application and will return to you.

thiagoloureiro commented 3 years ago

I've used your project and reproduced the error:

image

I've just used my log4net.config and problem appeared

Below my log4net.config

thiagoloureiro commented 3 years ago
<log4net>
    <appender name="Console" type="log4net.Appender.ConsoleAppender">
        <layout type="log4net.Layout.PatternLayout">
            <!-- Pattern to output the caller's file name and line number -->
            <conversionPattern value="%date %5level %logger.%method [%line] - MESSAGE: %message%newline %exception" />
        </layout>
    </appender>
    <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
        <file value="example.log" />
        <appendToFile value="true" />
        <maximumFileSize value="100KB" />
        <maxSizeRollBackups value="2" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%date %5level %logger.%method [%line] - MESSAGE: %message%newline %exception" />
        </layout>
    </appender>
    <appender name="GelfHttpAppender" type="Gelf4Net.Appender.GelfHttpAppender, Gelf4Net">
        <url value="http://solver-graylog.eastus.cloudapp.azure.com:12201/gelf" />
        <layout type="Gelf4Net.Layout.GelfLayout, Gelf4Net">
            <param name="AdditionalFields" value="Application:HttpAppender,version:1.0,envName:%Env%,stringLevel:%level" />
            <param name="Facility" value="Solver-API" />
            <param name="IncludeLocationInformation" value="true" />
            <param name="SendTimeStampAsString" value="false" />
            <!--Sets the full_message and short_message to the specified pattern-->
            <!--<param name="ConversionPattern" value="[%t] %c{1} - %m" />-->
        </layout>
    </appender>

    <appender name="AsyncGelfHttpAppender" type="Gelf4Net.Appender.AsyncGelfHttpAppender, Gelf4Net">
        <url value="http://solver-graylog.eastus.cloudapp.azure.com:12201/gelf" />
        <!-- Number of log lines to buffer for async send. Defaults to 10-->
        <bufferSize value="20" />
        <!-- Number of tasks to use for the async appender. 0 or fewer indicates one task per processor-->
        <threads value="2" />
        <layout type="Gelf4Net.Layout.GelfLayout, Gelf4Net">
            <param name="AdditionalFields" value="Application:AsyncHttpAppender,version:${version},envName:${cliente}, stringLevel:%level" />
            <param name="Facility" value="Solver-API" />
            <param name="IncludeLocationInformation" value="true" />
            <param name="SendTimeStampAsString" value="false" />
            <!--Sets the full_message and short_message to the specified pattern-->
            <!--<param name="ConversionPattern" value="[%t] %c{1} - %m" />-->
        </layout>
    </appender>
    <appender name="TraceAppender" type="log4net.Appender.TraceAppender">
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%date %5level %logger.%method [%line] - MESSAGE: %message%newline %exception" />
        </layout>
    </appender>
    <appender name="ConsoleAppender" type="log4net.Appender.ManagedColoredConsoleAppender">
        <mapping>
            <level value="ERROR" />
            <foreColor value="Red" />
        </mapping>
        <mapping>
            <level value="WARN" />
            <foreColor value="Yellow" />
        </mapping>
        <mapping>
            <level value="INFO" />
            <foreColor value="White" />
        </mapping>
        <mapping>
            <level value="DEBUG" />
            <foreColor value="Green" />
        </mapping>
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%date %5level %logger.%method [%line] - MESSAGE: %message%newline %exception" />
        </layout>
    </appender>
    <root>
        <level value="INFO" />

        <appender-ref ref="AsyncGelfHttpAppender" />
    </root>
</log4net>
jjchiw commented 3 years ago

Oki

I'll look into it during the week...

I really think is the <bufferSize value="20" />

Thanks :)

thiagoloureiro commented 3 years ago

Thank you! What value do you recommend using there? Somethiny bigger?

Sent from my iPhone

On 27 Apr 2021, at 00:47, jjchiw @.***> wrote:

 Oki

I'll look into it during the week...

I really think is the

Thanks :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

jjchiw commented 3 years ago

ufff

I think I messed up a little bit with the queue and the reconnection :(

I'll be back as soon as I fixed it

jjchiw commented 3 years ago

I think It's fixed :)

image

Thanks for the issue.... I will reopen it and wait for your response.... :)

thiagoloureiro commented 3 years ago

Problem fixed ! cheers mate!