logzio / logzio-logback-appender

Logback Appender that ships logs using HTTPs bulk
Apache License 2.0
25 stars 19 forks source link

Configurable name of log level field? #10

Closed vlki closed 1 year ago

vlki commented 8 years ago

Hey Logz.io team,

first thanks for maintaining this logback appender! We were able to add it into our java/tomcat app right after the MDC support was finished and all works great.

I encountered just one minor issue with the naming. When logging the level to logz.io, it is right now hardcoded to be sent in loglevel field, but we are already using property level when logging from other parts of our platform for signifying the level.

We are solving it right now by wrapping the logging into our own methods and adding level to MDC right before logging and removing right after like this:

MDC.put("level", "warn");
logger.warn("Some message ...");
MDC.remove("level");

But it would be great if such hack is not needed. Any chance the name of log level field might be configurable?

roiravhon commented 8 years ago

Hey @vlki ! Well actually, now the level names are determined by their logback representation, as you can see here: https://github.com/logzio/logzio-logback-appender/blob/master/src/main/java/io/logz/logback/LogzioSender.java#L371

Can you give me an example of the configuration you would want? As this is using the slf4j standard which most users would need.

BTW, this could also be achieved by logstash configuration by our side, you can drop us a line in chat and our support team can get that sorted out for you.

vlki commented 8 years ago

Thanks for the quick reply! Its not the actual level names ("error", "warn", ..."), but the log property name. Basically having the "loglevel" in following piece of code configurable to, in our case, "level".

// ...
logMessage.addProperty("loglevel",logLevelName);
// ...
roiravhon commented 8 years ago

Got you. @asafm WDYS?

And @vlki, as I said, in the meantime you can just ask support to rename that field for you.

vlki commented 8 years ago

@roiravhon Thanks! Renaming not needed on the logstash level, we already have it solved by adding level property using MDC.

asafm commented 8 years ago

I think we can easily add a configuration for the field names sent in the JSON, thus it will have a map of key fields like:


<fieldNames>
    <logLevel>loglevel</logLevel>
    <message>message</message>
</fieldNames>

On Tue, Sep 20, 2016 at 5:03 PM Jan Vlček notifications@github.com wrote:

@roiravhon https://github.com/roiravhon Thanks! Renaming not needed on the logstash level, we already have it solved by adding level property using MDC.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/logzio/logzio-logback-appender/issues/10#issuecomment-248310599, or mute the thread https://github.com/notifications/unsubscribe-auth/AA8Y8VS-2hiQKg0S4CFD074b2UY330Otks5qr-e-gaJpZM4KBj8H .

roiravhon commented 8 years ago

Ok, ill add it in a future release. @vlki Thanks for that!

vlki commented 8 years ago

Sounds great, thanks!