-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Syslog writer thread should be daemon thread #7
Comments
I've improved termination code in my app in order to ensure that all messages are flushed to papertrail before exiting:
Nevertheless, this is still a workaround. The library should work out of the box. |
Not sure if this is still relevant, but... A slightly less hacky way I got around this is importing syslog4j 0.9.46 from clojars: https://mvnrepository.com/artifact/org.syslog4j/syslog4j/0.9.46 That version should use daemon threads by default. Or for more explicit configuration: <!-- from readme example -->
<appender name="SYSLOG-TLS" class="com.papertrailapp.logback.Syslog4jAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%-5level %logger{35}: %m%n%xEx</pattern>
</layout>
<syslogConfig class="org.productivity.java.syslog4j.impl.net.tcp.ssl.SSLTCPNetSyslogConfig">
<host>localhost</host>
<port>514</port>
<ident>java-app</ident>
<maxMessageLength>128000</maxMessageLength>
<useDaemonThread>true</useDaemonThread> <!-- explicitly use daemon threads -->
</syslogConfig>
</appender> +1 that we shouldn't need these workarounds though. |
For anyone stumbling on this using gradle. I used the following build file: repositories {
maven { url "https://clojars.org/repo" }
}
dependencies {
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
compile (group: 'com.papertrailapp', name: 'logback-syslog4j', version: '1.0.0'){
exclude group:'org.syslog4j', module: 'syslog4j'
}
compile group: 'org.syslog4j', name: 'syslog4j', version: '0.9.46'
} And then (as @alexkuang showed) adding the following to the syslogConfig node: <useDaemonThread>true</useDaemonThread> <!-- explicitly use daemon threads --> |
My app is not exiting properly, because non-daemon syslog4j thread hangs in the background. Apparently there's some way to configure syslog4j to use daemon thread. What's more, daemon mode appears to be the default in recent versions, so maybe just upgrading would be enough.
Meantime I am calling System.exit(0) at the end of main() as a temporary workaround.
The text was updated successfully, but these errors were encountered: