Comments (7)
I'd like to try another, more consistent approach. I found the concept of PropertyDefiner in the logback documentation. That could be used to configure a custom 'HostnameProvider' in the current released version of logback-gelf:
<configuration>
<define name="myHostname" class="your.HostnameProvider"/>
<appender name="GELF" class="de.siegmar.logbackgelf.GelfUdpAppender">
<graylogHost>localhost</graylogHost>
<graylogPort>12201</graylogPort>
<encoder class="de.siegmar.logbackgelf.GelfEncoder">
<originHost>${myHostname}</originHost>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="GELF" />
</root>
</configuration>
Could you give it a spin?
from logback-gelf.
Thanks for the info!
I think, the freeze is caused by a DNS or local hosts misconfiguration. If the IP address cannot be resolved to a hostname via DNS or local hosts file, the timeout might occur. I do not plan to change the implementation, as it is already the most portable (and in my point of view correct) way to handle it.
But I created a way to allow a different configuration – check the supplier branch.
Please let me know, if this works for you.
from logback-gelf.
tested the new bench, the new HostnameSupplier successfully resolve my custom hostname, thanks a lot.
public class MyHostnameSupplier extends HostnameSupplier {
@Override
public String get() throws UnknownHostException {
return InetAddress.getLocalHost().getHostName() ;
}
}
from logback-gelf.
Thanks for your feedback! I merged the change (including a rename to HostnameProvider) to master in 36120e3. As this work is still work-in-progress, I keep this ticket open...
from logback-gelf.
i prefer using PropertyDefiner. the supplier branch works.
but this will not work in v2.1.0 because GelfUdpChunker must resolve buildHostname(), a version update is still required.
public class MyHostnameSupplier extends PropertyDefinerBase {
@Override
public String getPropertyValue() {
try {
return InetAddress.getLocalHost().getHostName() +" - (custom)";
} catch (UnknownHostException e) {
//e.printStackTrace();
addError("Error resolving host");
return "error";
}
}
}
from logback-gelf.
OK, thanks. Also note, that you could use the addError() method in your class to pass the exception to logback.
from logback-gelf.
I found the new GelfUdpChunker use different logic to resolve host (not using HostnameSupplier provided), although there is no issue for me.
if it does not matter, the issue could close.
from logback-gelf.
Related Issues (20)
- Ability to add custom fields to GelfMessage, computed from ILoggingEvent HOT 20
- Refactor JSON to byte array
- Improve test coverage
- Add the possibility to filter included MDC keys HOT 3
- Add a configurable socket timeout HOT 5
- Macbook GelfUdpAppender garbled HOT 2
- GZIP Compression with GelfUdpAppender HOT 1
- Update logback-classic to 1.2.8 HOT 3
- Logback-classic release 1.2.9
- tcp configuration error HOT 3
- Add ability to log thread ID in addition to thread name HOT 2
- Enable adding multiple static fields via environment variable and/or logback.properties HOT 2
- Mutual TLS fails, HOT 1
- Add another method for adding static field to GelfEncoder HOT 2
- GelfMessage should fail on host = "", shortmessage="" HOT 4
- Add ability to log formatted time HOT 1
- Add use of structured arguments HOT 1
- JSON Encoding Performance HOT 1
- Several minor improvements HOT 1
- Faster MessageIdSupplier with less object allocation, error-prone HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from logback-gelf.