Groovy configuration for logback based on hostname -
i trying configure logback dynamically using hostname setup specific property logger. initialize map following, before appender:
def hostname="${hostname}" def logentriestokens = [ "info03": "mytoken" ]
and following:
appender("logentriesappender",logentriesappender){ encoder(patternlayoutencoder) { pattern = "%d{dd mmm yyyy ; hh:mm:ss.sss} [%thread] %-5level %logger{36} - %msg%n" } token = logentriestokens[hostname] println hostname println logentriestoken println logentriestokens[hostname] println token ssl = false facility = "user" filter(thresholdfilter){ level = error } }
and result following:
info03 [info03:mytoken] mytoken null
for reason, token property not set (i can see investigating appenders hierarchy in java). if instead put constant , such token = "mytoken", works fine. wrong?
Comments
Post a Comment