jhipster / jhipster-lite

JHipster Lite ⚡ is a development platform to generate, develop & deploy modern web applications & microservices architecture, step by step - using Hexagonal Architecture :gem:
https://lite.jhipster.tech
Apache License 2.0
463 stars 212 forks source link

Reduce output log in generated projects #584

Closed pascalgrimaud closed 2 years ago

pascalgrimaud commented 2 years ago

When launching tests in a generated projects, there are still a lot of useless logs It means we should add more logger name to ignore in logback.xml

MSaguer commented 2 years ago

I can work in this

pascalgrimaud commented 2 years ago

Thanks @MSaguer If possible, small PR in each contexts would be cool :-)

MSaguer commented 2 years ago

@pascalgrimaud, I'm struggling with the traces generated by LogstashTcpLifeCycleTest unit test.

22:24:02,504 |-WARN in net.logstash.logback.appender.LogstashTcpSocketAppender[ASYNC_LOGSTASH_TCP] - Log destination localhost/127.0.0.1:5000: connection failed. java.net.ConnectException: Connection refused: no further information
    at java.net.ConnectException: Connection refused: no further information
    at  at java.base/sun.nio.ch.Net.pollConnect(Native Method)
    at  at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
Net.java:672
    at  at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:542)
NioSocketImpl.java:542
    at  at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597)
NioSocketImpl.java:597
    at  at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
SocksSocketImpl.java:327
    at  at java.base/java.net.Socket.connect(Socket.java:633)
Socket.java:633
    at  at net.logstash.logback.appender.AbstractLogstashTcpSocketAppender$TcpSendingEventHandler.openSocket(AbstractLogstashTcpSocketAppender.java:762)
AbstractLogstashTcpSocketAppender.java:762
    at  at net.logstash.logback.appender.AbstractLogstashTcpSocketAppender$TcpSendingEventHandler.onStart(AbstractLogstashTcpSocketAppender.java:681)
AbstractLogstashTcpSocketAppender.java:681
    at  at net.logstash.logback.appender.AsyncDisruptorAppender$EventClearingEventHandler.onStart(AsyncDisruptorAppender.java:382)
AsyncDisruptorAppender.java:382
    at  at net.logstash.logback.encoder.com.lmax.disruptor.BatchEventProcessor.notifyStart(BatchEventProcessor.java:224)
BatchEventProcessor.java:224
    at  at net.logstash.logback.encoder.com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:120)
BatchEventProcessor.java:120
    at  at java.base/java.lang.Thread.run(Thread.java:833)
Thread.java:833

I first though that it could be solved by setting logback configuration on 'net.logstash.logback' but it has no effect. Any idea?

pascalgrimaud commented 2 years ago

I'll have a look

pascalgrimaud commented 2 years ago

I tried and I didn't find the good configuration to ignore these logs. I think it's because of LogstashTcpLifeCycle which uses internal logger to send logs to Logstash. So we can simply ignore these logs for now:

Another solution would be to try to completely rework the LogstashTcpLifeCycleTest test, to transform to IntegrationTest, with Spring Context, but it's not deserved to spend too much time to reduce few lines of logs

pascalgrimaud commented 2 years ago

Following your other comment @MSaguer, I think there are some work before closing this ticket:

image

image

MSaguer commented 2 years ago

Unit tests seems OK for me but Integration Tests are not. It requires new needle in application-test.properties to be able to configure logging. It's in progress.

Here is its new content

spring.main.banner-mode=off

# Logging configuration
logging.level.{{packageName}}=OFF
# jhipster-needle-application-test-logging-properties

# jhipster-needle-application-test-properties
pascalgrimaud commented 2 years ago

I think we already have a good approach and lot of work has been done so this ticket can be closed

Plz claim the bounty @MSaguer

MSaguer commented 2 years ago

Hi @pascalgrimaud, here is the bounty claim https://opencollective.com/generator-jhipster/expenses/89915 With some delay :)

DanielFran commented 2 years ago

@MSaguer approved