2017-10-03 9 views
0

J'utilise la jetée pour implémenter le client websocket. Cela produit beaucoup de bruit dans le fichier journal au démarrage de l'application et lors de la reconnexion de la socket websocket. En fait, en cas d'échec de la connexion websocket je suis une nouvelle tentative après une minute si après chaque minute il il produire ce genre de journal:Comment arrêter la connexion dans l'application de jetée

2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.log:173 - Logging to Logger[org.eclipse.jetty.util.log] via org.eclipse.jetty.util.log.Slf4jLog 
2017-06-12 14:23:04 | INFO | [main] c.h.h.v.c.WebSocketListener:53 - STARTING WS Client 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.AbstractLifeCycle:184 - starting [email protected] 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.w.c.WebSocketClient:157 - Starting [email protected] 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.ContainerLifeCycle:302 - [email protected] added {[email protected]{STOPPED,8<=0<=200,i=0,q=0},AUTO} 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.ContainerLifeCycle:302 - [email protected] added {[email protected],POJO} 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.ContainerLifeCycle:302 - [email protected] added {[email protected]7,AUTO} 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.ContainerLifeCycle:302 - [email protected] added {[email protected],AUTO} 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.AbstractLifeCycle:184 - starting [email protected]{STOPPED,8<=0<=200,i=0,q=0} 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.AbstractLifeCycle:177 - STARTED [email protected]{STARTED,8<=8<=200,i=7,q=0} 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.AbstractLifeCycle:184 - starting [email protected]7 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.AbstractLifeCycle:177 - STARTED [email protected]7 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.AbstractLifeCycle:184 - starting [email protected] 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.ContainerLifeCycle:302 - [email protected] added {org.e[email protected]1cbbbc31,AUTO} 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.AbstractLifeCycle:184 - starting org.e[email protected]1cbbbc31 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.AbstractLifeCycle:184 - starting [email protected] keys=-1 selected=-1 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.AbstractLifeCycle:177 - STARTED [email protected] keys=0 selected=0 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.t.QueuedThreadPool:342 - [email protected]{STARTED,8<=8<=200,i=8,q=0} dispatched [email protected] keys=0 selected=0 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.AbstractLifeCycle:184 - starting [email protected] keys=-1 selected=-1 
2017-06-12 14:23:04 | DEBUG | [[email protected]] o.e.j.i.SelectorManager:418 - Starting Thread[[email protected],5,main] on [email protected] keys=0 selected=0 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.AbstractLifeCycle:177 - STARTED [email protected] keys=0 selected=0 
2017-06-12 14:23:04 | DEBUG | [[email protected]] o.e.j.i.SelectorManager:443 - Selector loop waiting on select 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.t.QueuedThreadPool:342 - [email protected]{STARTED,8<=8<=200,i=7,q=0} dispatched [email protected] keys=0 selected=0 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.AbstractLifeCycle:184 - starting [email protected]8 keys=-1 selected=-1 
2017-06-12 14:23:04 | DEBUG | [[email protected]] o.e.j.i.SelectorManager:418 - Starting Thread[[email protected],5,main] on [email protected] keys=0 selected=0 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.AbstractLifeCycle:177 - STARTED [email protected] keys=0 selected=0 
2017-06-12 14:23:04 | DEBUG | [[email protected]] o.e.j.i.SelectorManager:443 - Selector loop waiting on select 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.t.QueuedThreadPool:342 - [email protected]{STARTED,8<=8<=200,i=6,q=0} dispatched [email protected] keys=0 selected=0 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.AbstractLifeCycle:184 - starting [email protected] keys=-1 selected=-1 
2017-06-12 14:23:04 | DEBUG | [[email protected]] o.e.j.i.SelectorManager:418 - Starting Thread[[email protected],5,main] on [email protected] keys=0 selected=0 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.AbstractLifeCycle:177 - STARTED [email protected] keys=0 selected=0 
2017-06-12 14:23:04 | DEBUG | [[email protected]] o.e.j.i.SelectorManager:443 - Selector loop waiting on select 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.t.QueuedThreadPool:342 - [email protected]{STARTED,8<=8<=200,i=5,q=0} dispatched [email protected] keys=0 selected=0 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.AbstractLifeCycle:177 - STARTED org.e[email protected]1cbbbc31 
2017-06-12 14:23:04 | DEBUG | [[email protected]] o.e.j.i.SelectorManager:418 - Starting Thread[[email protected],5,main] on [email protected] keys=0 selected=0 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.AbstractLifeCycle:177 - STARTED [email protected] 
2017-06-12 14:23:04 | DEBUG | [[email protected]] o.e.j.i.SelectorManager:443 - Selector loop waiting on select 
2017-06-12 14:23:04 | INFO | [main] o.e.j.w.c.WebSocketClient:196 - Started [email protected] 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.c.AbstractLifeCycle:177 - STARTED [email protected] 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.w.c.WebSocketClient:136 - connect websocket:[email protected] to:ws://localhost:9900 
2017-06-12 14:23:04 | DEBUG | [main] o.e.j.u.t.QueuedThreadPool:342 - [email protected]{STARTED,8<=8<=200,i=4,q=0} dispatched [email protected]{true,false,null} 
2017-06-12 14:23:04 | DEBUG | [[email protected]] o.e.j.i.SelectorManager:379 - Queued change [email protected]8ad23 
2017-06-12 14:23:04 | DEBUG | [[email protected]] o.e.j.i.SelectorManager:446 - Selector loop woken up from select, 0/0 selected 
2017-06-12 14:23:04 | DEBUG | [[email protected]] o.e.j.i.SelectorManager:406 - Running change [email protected]8ad23 
2017-06-12 14:23:04 | DEBUG | [[email protected]] o.e.j.i.SelectorManager:443 - Selector loop waiting on select 
2017-06-12 14:23:04 | DEBUG | [[email protected]] o.e.j.i.SelectorManager:446 - Selector loop woken up from select, 1/1 selected 
2017-06-12 14:23:04 | DEBUG | [[email protected]] o.e.j.w.c.i.WebSocketClientSelectorManager:56 - Connection Failed 
java.net.ConnectException: Connection refused 
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) 
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739) 
    at org.eclipse.jetty.io.SelectorManager.finishConnect(SelectorManager.java:257) 
    at org.eclipse.jetty.io.SelectorManager$ManagedSelector.processConnect(SelectorManager.java:529) 
    at org.eclipse.jetty.io.SelectorManager$ManagedSelector.processKey(SelectorManager.java:502) 
    at org.eclipse.jetty.io.SelectorManager$ManagedSelector.select(SelectorManager.java:455) 
    at org.eclipse.jetty.io.SelectorManager$ManagedSelector.run(SelectorManager.java:420) 
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:596) 
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:527) 
    at java.lang.Thread.run(Thread.java:745) 
2017-06-12 14:23:04 | INFO | [[email protected]] c.h.h.v.c.WebSocketListener:94 - onWebSocketError: 
java.net.ConnectException: Connection refused 
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) 
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739) 
    at org.eclipse.jetty.io.SelectorManager.finishConnect(SelectorManager.java:257) 
    at org.eclipse.jetty.io.SelectorManager$ManagedSelector.processConnect(SelectorManager.java:529) 
    at org.eclipse.jetty.io.SelectorManager$ManagedSelector.processKey(SelectorManager.java:502) 
    at org.eclipse.jetty.io.SelectorManager$ManagedSelector.select(SelectorManager.java:455) 
    at org.eclipse.jetty.io.SelectorManager$ManagedSelector.run(SelectorManager.java:420) 
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:596) 
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:527) 
    at java.lang.Thread.run(Thread.java:745) 

Voici mon fichier logback.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 

    <appender name="AUDITFILE" 
       class="ch.qos.logback.core.rolling.RollingFileAppender"> 
     <file>logs/visma-websocket-client.log</file> 
     <append>true</append> 
     <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> 
      <fileNamePattern>logs/visma-websocket-client_%d{yyyy-MM-dd}.%i.log 
      </fileNamePattern> 
      <maxHistory>10</maxHistory> 
      <timeBasedFileNamingAndTriggeringPolicy 
        class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> 
       <maxFileSize>20MB</maxFileSize> 

      </timeBasedFileNamingAndTriggeringPolicy> 
     </rollingPolicy> 
     <encoder> 
      <pattern>%date %msg%n 
      </pattern> 
     </encoder> 
    </appender> 

    <root level="DEBUG"> 
     <appender-ref ref="AUDITFILE" /> 
    </root> 

</configuration> 

Quelqu'un peut-il donner Je suggère comment je peux réduire cette journalisation inutilisée car elle crée beaucoup d'espace disque lorsque le programme est en cours d'exécution. Je me demande est-il possible d'activer désactiver ce journal de la jetée de l'application ou en ajoutant un paramètre dans le fichier logback.xml

+0

Augmenter le 'niveau' ?? – Oleg

+0

vous voulez dire niveau = "DEBUG" à Info? Est-ce que cela aide aussi le niveau de journalisation de la jetée? – user565

Répondre

0
<root level="INFO"> 
     <appender-ref ref="AUDITFILE" /> 
</root> 

Cela devrait fonctionner. Vous pouvez encore augmenter le niveau dans votre fichier xml pour WARN, ERROR or FATAL.

3

Si vous souhaitez désactiver complètement seulement les journaux de la jetée, vous pouvez ajouter la ligne suivante:

<configuration> 
... 
    <logger name="org.eclipse.jetty" level="OFF" /> 
.... 
</configuration> 

Vous pouvez également changer pour ERROR si vous veulent juste les messages de niveau d'erreur.

Augmenter le <root level="DEBUG"> à un niveau supérieur affecte l'ensemble de l'application et les journaux de la jetée.

0

Toutes les instructions de journal sont imprimées car le consignateur racine a le niveau DEBUG et est associé à l'appender AUDITFILE.

Vous pouvez définir différents niveaux de journalisation ou différents appenders en fonction des packages. Dans votre cas, ajoutez la ligne suivante dans l'élément de configuration.

<logger name="org.eclipse.jetty" level="WARN"/> 

Cela fera une déclaration de journal des paquets qui commencent comme org.eclipse.jetty d'utiliser un niveau de journalisation des WARN. Ce qui signifie que seules les instructions WARN ou ci-dessus seront enregistrées. Réglez le niveau sur "OFF" pour désactiver la journalisation pour le package.

Au cas où vous voulez quand même les déclarations, mais dans un appender différent, vous pouvez alors faire,

<logger name="org.eclipse.jetty" additivity="false"> 
    <appender-ref ref="AUDIT_FILE_NEW" /> 
</logger> 

On suppose que AUDIT_FILE_NEW est une autre implémentation appender qui se connecte à un autre fichier ou à la console. Ici additivité est mis à false, de sorte que les déclarations sont enregistrées uniquement dans l'appender AUDIT_FILE_NEW. Dans le cas où l'additivité n'était pas définie, elle prend par défaut la valeur true, ce qui signifie que l'enregistreur héritera de l'enregistreur racine. Et les déclarations seront consignées dans les appenders AUDIT_FILE et AUDIT_FILE_NEW.