Hello,
I’m very confused with Pax Logging configuration. For example, on the wiki https://ops4j1.jira.com/wiki/spaces/ops4j/pages/7274541/Configuring+Pax+Logging the layout is configured this way:
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
However, In org.ops4j.pax.logging.cfg in Karaf distribution I have:
log4j2.appender.console.layout.type = PatternLayout
In first syntax, I see how I could replace standart PatternLayout with my own, in that what is actually used in Karaf I don’t know where I should start…
I need (most likely) to customize PatternLayout because I’m using Dockerized karaf and Elasticsearch, which together have no support for multiline messages. So if Java logs something multi-line like StackTrace, my Patter need to convert the message to single-line.
Is there any entry point I can start doing my research? Honestly, pax logging is the part that is still a black magic to me. That what I see in config file differs from both log4j property-based documentation and that what can be found on wiki, every time I’m changing there something I do it through experimenting…
Best regards,
Lukasz Lech
--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thanks, now I’ve found the solution
I’ve searched for JsonLayout configuration in log4j and I’ve adapted the ‘rolling’ appender deifiition to
# Rolling file appender
log4j2.appender.rolling.type = RollingRandomAccessFile
log4j2.appender.rolling.name = RollingFile
log4j2.appender.rolling.fileName = ${karaf.data}/log/karaf.log
log4j2.appender.rolling.filePattern = ${karaf.data}/log/karaf.log.%i
log4j2.appender.rolling.append = true
log4j2.appender.rolling.layout.type = JsonLayout
log4j2.appender.rolling.layout.compact = true
log4j2.appender.rolling.layout.eventEol = true
log4j2.appender.rolling.policies.type = Policies
log4j2.appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
log4j2.appender.rolling.policies.size.size = 16MB
It required to install 3 additional bundles to fulfill the dependencies:
mvn:com.fasterxml.jackson.core/jackson-core/2.9.5
mvn:com.fasterxml.jackson.core/jackson-annotations/2.9.0
mvn:com.fasterxml.jackson.core/jackson-databind/2.9.5
Now I have 1 line with json log per logging event. I hope it will help others who’d like to achieve the same.
Best regards,
Lukasz Lech
--
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
--
------------------
OPS4J - http://www.ops4j.org -
op...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.