Giter VIP home page Giter VIP logo

Comments (7)

osiegmar avatar osiegmar commented on May 25, 2024 1

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.

osiegmar avatar osiegmar commented on May 25, 2024

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.

chouex avatar chouex commented on May 25, 2024

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.

osiegmar avatar osiegmar commented on May 25, 2024

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.

chouex avatar chouex commented on May 25, 2024

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.

osiegmar avatar osiegmar commented on May 25, 2024

OK, thanks. Also note, that you could use the addError() method in your class to pass the exception to logback.

from logback-gelf.

chouex avatar chouex commented on May 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.