How to add new config parameters in server.cof

i want to add new config param in server.conf and read it

how can i do it ??

Graylog is using JadConfig for reading and processing its configuration files.

See https://joschi.github.io/JadConfig/0.13.0/apidocs/index.html for the respective Javadoc.

For the Graylog side of things, you can take a look at the Configuration class:

i added a new param say xxxx = 10 in .conf file

and in configuration.java i added

@Parameter(value = “xxxx”, required = true)
private String xxxx;

and created setter and getter like this

public String getXxxx() {
    return xxxx;
}

public void setxxxx(String s) {
    xxxx = s;
}

but still i wont get getXxxx() method in configuration class instance

am i doing anything wrong ??

Thanks
Manju

That should work.

What did you change specifically, what did you expect to happen, and how did you test it?

i want to add an param xyz in .conf file and i want to use it in java

i expect getxxx() method to be available in config instance

i just made above modification and created instance of configuration class and tryed to access like conf.getxxx() even tried doing mvn compile but no luck

Please describe step-by-step what you did and what the result of the step was.

FWIW, it works for me.™

Step1:
add a parameter pluginenable in config file
image

Step2:
declare it in configuration.java like this

image

and create setter and getter

image

Step3:

i’m creating instance of configuration class and trying to access the isPluginenable() method
image

hey it works in graylog2-server 's code

actually i’m trying to read it in an graylog-plugin which i’m writing

is there anything i should do ??

Thanks
Manju

Yes, you have to include the changed graylog2-server artifact in your project, e. g. by running mvn install in the graylog2-server repository so that it’s installed in the local Maven repository cache (see ~/.m2/repository/).

There was an version mismatch in dependency

thanks for pointing it out :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.