Code-Sharp / WampSharp

A C# implementation of WAMP (The Web Application Messaging Protocol)
http://wampsharp.net
Other
385 stars 83 forks source link

Disable Logging #331

Closed xxdamxx closed 3 years ago

xxdamxx commented 3 years ago

I have a REST API. I have some requests calling a WAMP client, I have default log4Net as a logger and no matter how hard I have searched, I cannot find the option to disable WAMP log messages (WampSharp.V2.Core.Contracts.HelloDetails, WampSharp. V2 .Core.Contracts.ChallengeDetails, WampSharp.V2.Core.Contracts.WelcomeDetails, WampSharp.V2.Core.Contracts.ResultDetails). I want this functionality to be user configurable and not something fixed or preferably disable permanently.

Example logger file [i]2021-04-07T02:08:57.273[;]DEBUG[;]7[;] Configuration Configuration loaded [i]2021-04-07T02:08:57.278[;]DEBUG[;]7[;] Implementation End [i]2021-04-07T02:09:04.196[;]DEBUG[;]8[;] Calling remote peer proxy method: Void Hello(System.String, WampSharp.V2.Core.Contracts.HelloDetails) [i]2021-04-07T02:09:04.210[;]DEBUG[;]10[;] Attempting to send a message [i]2021-04-07T02:09:04.253[;]DEBUG[;]10[;] Formatted message [1,"realm1",{"roles":{"caller":{"features":{"caller_identification":true,"call_canceling":true,"progressive_call_results":true}},"callee":{"features":{"caller_identification":true,"pattern_based_registration":true,"shared_registration":true,"call_canceling":true,"progressive_call_results":true}},"publisher":{"features":{"publisher_identification":true,"subscriber_blackwhite_listing":true,"publisher_exclusion":true}},"subscriber":{"features":{"publisher_identification":true,"pattern_based_subscription":true}}},"authmethods":["wampcra"],"authid":"sysce"}] [i]2021-04-07T02:09:04.272[;]DEBUG[;]6[;] Trying to parse message [4,"wampcra",{"challenge":"{\"nonce\": \"AkddFusm20KFVb9aU6AKcA==\", \"authprovider\": \"static\", \"authid\": \"sysce\", \"timestamp\": \"2021-04-07T07:09:04Z\", \"authrole\": \"admin\", \"authmethod\": \"wampcra\", \"session\": 28530234775267}"}] [i]2021-04-07T02:09:04.275[;]DEBUG[;]6[;] Mapped message to method: Void Challenge(System.String, WampSharp.V2.Core.Contracts.ChallengeDetails) [i]2021-04-07T02:09:04.307[;]DEBUG[;]6[;] Calling remote peer proxy method: Void Authenticate(System.String, WampSharp.V2.Core.Contracts.AuthenticateExtraData) [i]2021-04-07T02:09:04.324[;]DEBUG[;]10[;] Attempting to send a message [i]2021-04-07T02:09:04.329[;]DEBUG[;]10[;] Formatted message [5,"cYzgp12GVrzwpQ5V5sh9zdrj4Y5d4D9/F6m+kAhn6hc=",{}] [i]2021-04-07T02:09:04.339[;]DEBUG[;]5[;] Trying to parse message [2,28530234775267,{"authrole":"admin","authmethod":"wampcra","authprovider":"static","roles":{"dealer":{"features":{"caller_identification":true,"pattern_based_registration":true,"shared_registration":true,"call_canceling":true,"progressive_call_results":true}},"broker":{"features":{"publisher_identification":true,"pattern_based_subscription":true,"subscriber_blackwhite_listing":true,"publisher_exclusion":true,"event_retention":true}}},"authid":"sysce"}] [i]2021-04-07T02:09:04.340[;]DEBUG[;]5[;] Mapped message to method: Void Welcome(Int64, WampSharp.V2.Core.Contracts.WelcomeDetails) [i]2021-04-07T02:09:04.392[;]DEBUG[;]9[;]

Can someone help me?

Thanks.

darkl commented 3 years ago

log4net supports configuring log levels per namespace. Just set the log level of the namespace WampSharp to ERROR.

Elad

On Wed, Apr 7, 2021, 03:27 xxdamxx @.***> wrote:

Tengo una API REST. Tengo algunas solicitudes que llaman a un cliente WAMP, tengo log4Net por defecto como registrador y no importa lo mucho que haya buscado, no puedo encontrar la opción para deshabilitar los mensajes de registro WAMP (WampSharp.V2.Core.Contracts.HelloDetails, WampSharp.V2 .Core.Contracts.ChallengeDetails, WampSharp.V2.Core.Contracts.WelcomeDetails, WampSharp.V2.Core.Contracts.ResultDetails). Quiero que esta funcionalidad sea configurable para el usuario y no algo fijo o preferiblemente deshabilitarlo permanentemente.

Example logger file [i]2021-04-07T02:08:57.273[;]DEBUG[;]7[;] Configuration Configuration loaded [i]2021-04-07T02:08:57.278[;]DEBUG[;]7[;] Implementation End [i]2021-04-07T02:09:04.196[;]DEBUG[;]8[;] Calling remote peer proxy method: Void Hello(System.String, WampSharp.V2.Core.Contracts.HelloDetails) [i]2021-04-07T02:09:04.210[;]DEBUG[;]10[;] Attempting to send a message [i]2021-04-07T02:09:04.253[;]DEBUG[;]10[;] Formatted message [1,"realm1",{"roles":{"caller":{"features":{"caller_identification":true,"call_canceling":true,"progressive_call_results":true}},"callee":{"features":{"caller_identification":true,"pattern_based_registration":true,"shared_registration":true,"call_canceling":true,"progressive_call_results":true}},"publisher":{"features":{"publisher_identification":true,"subscriber_blackwhite_listing":true,"publisher_exclusion":true}},"subscriber":{"features":{"publisher_identification":true,"pattern_based_subscription":true}}},"authmethods":["wampcra"],"authid":"sysce"}] [i]2021-04-07T02:09:04.272[;]DEBUG[;]6[;] Trying to parse message [4,"wampcra",{"challenge":"{\"nonce\": \"AkddFusm20KFVb9aU6AKcA==\", \"authprovider\": \"static\", \"authid\": \"sysce\", \"timestamp\": \"2021-04-07T07:09:04Z\", \"authrole\": \"admin\", \"authmethod\": \"wampcra\", \"session\": 28530234775267}"}] [i]2021-04-07T02:09:04.275[;]DEBUG[;]6[;] Mapped message to method: Void Challenge(System.String, WampSharp.V2.Core.Contracts.ChallengeDetails) [i]2021-04-07T02:09:04.307[;]DEBUG[;]6[;] Calling remote peer proxy method: Void Authenticate(System.String, WampSharp.V2.Core.Contracts.AuthenticateExtraData) [i]2021-04-07T02:09:04.324[;]DEBUG[;]10[;] Attempting to send a message [i]2021-04-07T02:09:04.329[;]DEBUG[;]10[;] Formatted message [5,"cYzgp12GVrzwpQ5V5sh9zdrj4Y5d4D9/F6m+kAhn6hc=",{}] [i]2021-04-07T02:09:04.339[;]DEBUG[;]5[;] Trying to parse message [2,28530234775267,{"authrole":"admin","authmethod":"wampcra","authprovider":"static","roles":{"dealer":{"features":{"caller_identification":true,"pattern_based_registration":true,"shared_registration":true,"call_canceling":true,"progressive_call_results":true}},"broker":{"features":{"publisher_identification":true,"pattern_based_subscription":true,"subscriber_blackwhite_listing":true,"publisher_exclusion":true,"event_retention":true}}},"authid":"sysce"}] [i]2021-04-07T02:09:04.340[;]DEBUG[;]5[;] Mapped message to method: Void Welcome(Int64, WampSharp.V2.Core.Contracts.WelcomeDetails) [i]2021-04-07T02:09:04.392[;]DEBUG[;]9[;]

Can someone help me?

Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Code-Sharp/WampSharp/issues/331, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIS75VAJJMH6K3R3IEAR3DTHQCM7ANCNFSM42QG26LA .

xxdamxx commented 3 years ago

log4net supports configuring log levels per namespace. Just set the log level of the namespace WampSharp to ERROR. Elad On Wed, Apr 7, 2021, 03:27 xxdamxx @.***> wrote: Tengo una API REST. Tengo algunas solicitudes que llaman a un cliente WAMP, tengo log4Net por defecto como registrador y no importa lo mucho que haya buscado, no puedo encontrar la opción para deshabilitar los mensajes de registro WAMP (WampSharp.V2.Core.Contracts.HelloDetails, WampSharp.V2 .Core.Contracts.ChallengeDetails, WampSharp.V2.Core.Contracts.WelcomeDetails, WampSharp.V2.Core.Contracts.ResultDetails). Quiero que esta funcionalidad sea configurable para el usuario y no algo fijo o preferiblemente deshabilitarlo permanentemente. Example logger file [i]2021-04-07T02:08:57.273[;]DEBUG[;]7[;] Configuration Configuration loaded [i]2021-04-07T02:08:57.278[;]DEBUG[;]7[;] Implementation End [i]2021-04-07T02:09:04.196[;]DEBUG[;]8[;] Calling remote peer proxy method: Void Hello(System.String, WampSharp.V2.Core.Contracts.HelloDetails) [i]2021-04-07T02:09:04.210[;]DEBUG[;]10[;] Attempting to send a message [i]2021-04-07T02:09:04.253[;]DEBUG[;]10[;] Formatted message [1,"realm1",{"roles":{"caller":{"features":{"caller_identification":true,"call_canceling":true,"progressive_call_results":true}},"callee":{"features":{"caller_identification":true,"pattern_based_registration":true,"shared_registration":true,"call_canceling":true,"progressive_call_results":true}},"publisher":{"features":{"publisher_identification":true,"subscriber_blackwhite_listing":true,"publisher_exclusion":true}},"subscriber":{"features":{"publisher_identification":true,"pattern_based_subscription":true}}},"authmethods":["wampcra"],"authid":"sysce"}] [i]2021-04-07T02:09:04.272[;]DEBUG[;]6[;] Trying to parse message [4,"wampcra",{"challenge":"{\"nonce\": \"AkddFusm20KFVb9aU6AKcA==\", \"authprovider\": \"static\", \"authid\": \"sysce\", \"timestamp\": \"2021-04-07T07:09:04Z\", \"authrole\": \"admin\", \"authmethod\": \"wampcra\", \"session\": 28530234775267}"}] [i]2021-04-07T02:09:04.275[;]DEBUG[;]6[;] Mapped message to method: Void Challenge(System.String, WampSharp.V2.Core.Contracts.ChallengeDetails) [i]2021-04-07T02:09:04.307[;]DEBUG[;]6[;] Calling remote peer proxy method: Void Authenticate(System.String, WampSharp.V2.Core.Contracts.AuthenticateExtraData) [i]2021-04-07T02:09:04.324[;]DEBUG[;]10[;] Attempting to send a message [i]2021-04-07T02:09:04.329[;]DEBUG[;]10[;] Formatted message [5,"cYzgp12GVrzwpQ5V5sh9zdrj4Y5d4D9/F6m+kAhn6hc=",{}] [i]2021-04-07T02:09:04.339[;]DEBUG[;]5[;] Trying to parse message [2,28530234775267,{"authrole":"admin","authmethod":"wampcra","authprovider":"static","roles":{"dealer":{"features":{"caller_identification":true,"pattern_based_registration":true,"shared_registration":true,"call_canceling":true,"progressive_call_results":true}},"broker":{"features":{"publisher_identification":true,"pattern_based_subscription":true,"subscriber_blackwhite_listing":true,"publisher_exclusion":true,"event_retention":true}}},"authid":"sysce"}] [i]2021-04-07T02:09:04.340[;]DEBUG[;]5[;] Mapped message to method: Void Welcome(Int64, WampSharp.V2.Core.Contracts.WelcomeDetails) [i]2021-04-07T02:09:04.392[;]DEBUG[;]9[;] Can someone help me? Thanks. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#331>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIS75VAJJMH6K3R3IEAR3DTHQCM7ANCNFSM42QG26LA .

I don't know how to configure what you say, could you help me with an example? Thanks.

xxdamxx commented 3 years ago

log4net supports configuring log levels per namespace. Just set the log level of the namespace WampSharp to ERROR. Elad On Wed, Apr 7, 2021, 03:27 xxdamxx @.***> wrote: Tengo una API REST. Tengo algunas solicitudes que llaman a un cliente WAMP, tengo log4Net por defecto como registrador y no importa lo mucho que haya buscado, no puedo encontrar la opción para deshabilitar los mensajes de registro WAMP (WampSharp.V2.Core.Contracts.HelloDetails, WampSharp.V2 .Core.Contracts.ChallengeDetails, WampSharp.V2.Core.Contracts.WelcomeDetails, WampSharp.V2.Core.Contracts.ResultDetails). Quiero que esta funcionalidad sea configurable para el usuario y no algo fijo o preferiblemente deshabilitarlo permanentemente. Example logger file [i]2021-04-07T02:08:57.273[;]DEBUG[;]7[;] Configuration Configuration loaded [i]2021-04-07T02:08:57.278[;]DEBUG[;]7[;] Implementation End [i]2021-04-07T02:09:04.196[;]DEBUG[;]8[;] Calling remote peer proxy method: Void Hello(System.String, WampSharp.V2.Core.Contracts.HelloDetails) [i]2021-04-07T02:09:04.210[;]DEBUG[;]10[;] Attempting to send a message [i]2021-04-07T02:09:04.253[;]DEBUG[;]10[;] Formatted message [1,"realm1",{"roles":{"caller":{"features":{"caller_identification":true,"call_canceling":true,"progressive_call_results":true}},"callee":{"features":{"caller_identification":true,"pattern_based_registration":true,"shared_registration":true,"call_canceling":true,"progressive_call_results":true}},"publisher":{"features":{"publisher_identification":true,"subscriber_blackwhite_listing":true,"publisher_exclusion":true}},"subscriber":{"features":{"publisher_identification":true,"pattern_based_subscription":true}}},"authmethods":["wampcra"],"authid":"sysce"}] [i]2021-04-07T02:09:04.272[;]DEBUG[;]6[;] Trying to parse message [4,"wampcra",{"challenge":"{\"nonce\": \"AkddFusm20KFVb9aU6AKcA==\", \"authprovider\": \"static\", \"authid\": \"sysce\", \"timestamp\": \"2021-04-07T07:09:04Z\", \"authrole\": \"admin\", \"authmethod\": \"wampcra\", \"session\": 28530234775267}"}] [i]2021-04-07T02:09:04.275[;]DEBUG[;]6[;] Mapped message to method: Void Challenge(System.String, WampSharp.V2.Core.Contracts.ChallengeDetails) [i]2021-04-07T02:09:04.307[;]DEBUG[;]6[;] Calling remote peer proxy method: Void Authenticate(System.String, WampSharp.V2.Core.Contracts.AuthenticateExtraData) [i]2021-04-07T02:09:04.324[;]DEBUG[;]10[;] Attempting to send a message [i]2021-04-07T02:09:04.329[;]DEBUG[;]10[;] Formatted message [5,"cYzgp12GVrzwpQ5V5sh9zdrj4Y5d4D9/F6m+kAhn6hc=",{}] [i]2021-04-07T02:09:04.339[;]DEBUG[;]5[;] Trying to parse message [2,28530234775267,{"authrole":"admin","authmethod":"wampcra","authprovider":"static","roles":{"dealer":{"features":{"caller_identification":true,"pattern_based_registration":true,"shared_registration":true,"call_canceling":true,"progressive_call_results":true}},"broker":{"features":{"publisher_identification":true,"pattern_based_subscription":true,"subscriber_blackwhite_listing":true,"publisher_exclusion":true,"event_retention":true}}},"authid":"sysce"}] [i]2021-04-07T02:09:04.340[;]DEBUG[;]5[;] Mapped message to method: Void Welcome(Int64, WampSharp.V2.Core.Contracts.WelcomeDetails) [i]2021-04-07T02:09:04.392[;]DEBUG[;]9[;] Can someone help me? Thanks. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#331>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIS75VAJJMH6K3R3IEAR3DTHQCM7ANCNFSM42QG26LA .

I tried, but it didn't work.

` <?xml version="1.0" encoding="utf-8" ?>

`
darkl commented 3 years ago

Yeah, because you need to disable the logger of WampSharp. Some of the logs like the Json/MessagePack loggers come from a different namespace which is shared among WAMP1 and WAMP2 implementations.

This logger config works for me.

<log4net>
    <!-- A1 is set to be a ConsoleAppender -->
    <appender name="A1" type="log4net.Appender.ConsoleAppender">

        <!-- A1 uses PatternLayout -->
        <layout type="log4net.Layout.PatternLayout">
            <!-- Print the date in ISO 8601 format -->
            <conversionPattern value="%date [%thread] %-5level %logger %ndc - %message%newline" />
        </layout>
    </appender>

    <!-- Set root logger level to DEBUG and its only appender to A1 -->
    <root>
        <level value="DEBUG" />
        <appender-ref ref="A1" />
    </root>

    <!-- Don't print messages from the package WampSharp -->
    <logger name="WampSharp">
        <level value="OFF" />
    </logger>
</log4net>
xxdamxx commented 3 years ago

It's works for me. Your help was very valuable to me.

Thanks.