Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@YuitoSato
Copy link
Contributor

@YuitoSato YuitoSato commented May 12, 2018

Pull Request Checklist

Helpful things

Fixes

Fixes #8277

Purpose

This PR adds graceful shutdown setting to the default logback which uses AsyncAppender.

@lightbend-cla-validator

Hi @YuitoSato,

Thank you for your contribution! We really value the time you've taken to put this together.

Before we proceed with reviewing this pull request, please sign the Lightbend Contributors License Agreement:

http://www.lightbend.com/contribute/cla

@YuitoSato
Copy link
Contributor Author

done with signing the CLA.

@YuitoSato YuitoSato changed the title add shutdown hook to logback-play-default.xml #8277 #8277 logback graceful shutdown May 12, 2018
@YuitoSato YuitoSato changed the title #8277 logback graceful shutdown 【WIP】#8277 logback graceful shutdown May 12, 2018
@YuitoSato YuitoSato closed this May 12, 2018
@YuitoSato YuitoSato reopened this May 12, 2018
@YuitoSato YuitoSato changed the title 【WIP】#8277 logback graceful shutdown WIP #8277 logback graceful shutdown May 12, 2018
@YuitoSato YuitoSato changed the title WIP #8277 logback graceful shutdown #8277 logback graceful shutdown May 12, 2018
@YuitoSato YuitoSato changed the title #8277 logback graceful shutdown logback graceful shutdown May 12, 2018
* These default configs specify only a console logger which outputs only 10 lines of an exception stack trace.
* Play uses ANSI color codes by default in level messages.
* For production, the default config puts the console logger behind the logback [AsyncAppender](https://logback.qos.ch/manual/appenders.html#AsyncAppender). For details on the performance implications on this, see this [blog post](https://blog.takipi.com/how-to-instantly-improve-your-java-logging-with-7-logback-tweaks/).
* In order to guarantee that logged messages have had a chance to be processed by asynchronous appenders (including the TCP appender) and ensure background threads have been stopped, you'll need to cleanly shut down logback when your application exits.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good, but we want to have the line explicitly included:

<shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>

along with a link to https://logback.qos.ch/manual/configuration.html#shutdownHook and https://jira.qos.ch/browse/LOGBACK-1090

@YuitoSato
Copy link
Contributor Author

YuitoSato commented May 16, 2018

Thanks @wsargent.
You mean that it is necessary to include the two links, don't you?
Am I supposed to explain why DelayingShutdownHook should be used in the document?

@wsargent wsargent merged commit 4a2aa85 into playframework:master Jun 14, 2018
Kavit900 added a commit to Kavit900/playframework that referenced this pull request Jun 14, 2018
* remove apache commons libs (playframework#8455)

* remove apache commons libs

currently play added a lot of "helper" libraries in the past,
however with recent JVM upgrades and more and more stuff inside
the JVM itself these got more and more unnecessary.

Actually this imports some Classes from apache commons lang3,
however only a really small subset of the library is imported.
The subset itself barly changed over the recent years and Play
mostly used just the reflect stuff of commons lang3

* Remove set current app when allow global false (playframework#8462)

* Remove imports to current app

* Add missing deprecation notes

* Remove invalid scaladoc tags

There is no `@deprecated` tag in scaladocs since we have
the `@deprecated` annotation.

* Do not set current app when global state is disabled

* Configure mima filter

* Clear warn messages when using global state

* Just stop the current app if global state is enabled

* logback graceful shutdown (playframework#8407)

* add shutdown hook to logback-play-default.xml playframework#8277

* update SettingsLogger.md documentation playframework#8277

* delete an unnecessary line playframework#8277.

* add shutdown hook to logback-play-logSql.xml playframework#8277

* add line playframework#8277

* update SettingsLogger.md playframework#8277

* update SettingsLogger.md playframework#8277
marcospereira pushed a commit that referenced this pull request Jul 16, 2018
* add shutdown hook to logback-play-default.xml #8277

* update SettingsLogger.md documentation #8277

* delete an unnecessary line #8277.

* add shutdown hook to logback-play-logSql.xml #8277

* add line #8277

* update SettingsLogger.md #8277

* update SettingsLogger.md #8277
@marcospereira
Copy link
Member

2.6.x: 3aa4930

@mkurz
Copy link
Member

mkurz commented Nov 10, 2022

Starting with Play 2.7, adding <shutdownHook /> to the logback config is a very bad idea, because you very likely even miss log entries. As of 2.7, Play handles the shutdown of the logger context with it's coordinated shutdown hooks. See #11532 where I revert his pull request (and more explanation).
(Of course back in the day when this PR was merged it might was a good idea)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Async appender should use shutdown hook for logback graceful shutdown

5 participants