Julia
Julia

Reputation: 173

How to set JsonTemplateLayout eventTemplateUri outside of classpath in Log4j2

In Log4j2's JsonTemplateLayout, I have no problem using eventTemplateUri: "classpath:LayoutTemplate.jsson" with json file located in rc/main/resources. However, I would need to keep this file outside of class path. so I would like to use file location something like he way we add log fileName: c:\...

But it's throwing an error when I use eventTemplateUri: "C:\ ....\LayoutTemplate.json"

rror message is " Could not create plugin of type class org.apache.logging.log4j.layout.template.json.JsonTemplateLa yout for element JsonTemplateLayout: java.lang.RuntimeException: failed reading URI: C:... Did I miss anything here? is it possible to place this json file outside of class path?

Thanks!

Upvotes: 2

Views: 4324

Answers (1)

Volkan Yazıcı
Volkan Yazıcı

Reputation: 1916

All *Uri configuration knobs in JsonTemplateLayout expect a URI string. In your case, the URI scheme is missing. The eventTemplateUri should look like file:///C:/path/to/LayoutTemplate.json in your case. For internals, see how o.a.l.l.l.template.json.util.Uris.readUri(String,Charset) is implemented.

Upvotes: 2

Related Questions