Question

Allianz Technology
DE
Last activity: 11 Mar 2020 14:42 EDT
Log4j Regefilter not working for multiline log message
My application is currently printing logs as below, however, I need a regular expression to print the content inside {}
in a separate file.
<!-- RollingFile Appender for Elastic logs --> <RollingRandomAccessFile name="ElasticNew" fileName="${sys:pega.logdir}/ElasticNew.log" filePattern="${sys:pega.logdir}/PegaRULES-%d{MM-dd-yyyy}-%i.log.gz"> <RegexFilter regex="/{([^}]+)}/" onMatch="ACCEPT" onMismatch="DENY"/> <PatternLayout> <pattern>%d %X{userid}-%m%n</pattern> </PatternLayout> <Policies> <TimeBasedTriggeringPolicy /> <SizeBasedTriggeringPolicy size="250 MB"/> </Policies> </RollingRandomAccessFile>
Log:
2020-03-11 18:56:56,723 [http-nio-8080-exec-9] [TABTHREAD1] [ ] [ SrMgmt:01.01.01] ( mgmt.util.URLAccessContext) WARN localhost|0:0:0:0:0:0:0:1 - URLAccessModeWarn:URLAccessPermitted URLAccessDetail ActionTampered IActionRequest class instance is null. None of the parameters(fixed/enum/client) got registered.
2020-03-11 18:56:57,540 [http-nio-8080-exec-9] [TABTHREAD1] [ ] [ SrMgmt:01.01.01] (gmt_Work_ServiceRequest.Action) INFO localhost|0:0:0:0:0:0:0:1 Admin.SrMgmt - {
"pxObjClass":"Data-Party-Person"
,"pyID":"S-40"
}
expected Log to be printed in another file:
2020-03-11 18:56:57,540 [http-nio-8080-exec-9] [TABTHREAD1] [ ] [ SrMgmt:01.01.01] (gmt_Work_ServiceRequest.Action) INFO localhost|0:0:0:0:0:0:0:1 Admin.SrMgmt - {
My application is currently printing logs as below, however, I need a regular expression to print the content inside {}
in a separate file.
<!-- RollingFile Appender for Elastic logs --> <RollingRandomAccessFile name="ElasticNew" fileName="${sys:pega.logdir}/ElasticNew.log" filePattern="${sys:pega.logdir}/PegaRULES-%d{MM-dd-yyyy}-%i.log.gz"> <RegexFilter regex="/{([^}]+)}/" onMatch="ACCEPT" onMismatch="DENY"/> <PatternLayout> <pattern>%d %X{userid}-%m%n</pattern> </PatternLayout> <Policies> <TimeBasedTriggeringPolicy /> <SizeBasedTriggeringPolicy size="250 MB"/> </Policies> </RollingRandomAccessFile>
Log:
2020-03-11 18:56:56,723 [http-nio-8080-exec-9] [TABTHREAD1] [ ] [ SrMgmt:01.01.01] ( mgmt.util.URLAccessContext) WARN localhost|0:0:0:0:0:0:0:1 - URLAccessModeWarn:URLAccessPermitted URLAccessDetail ActionTampered IActionRequest class instance is null. None of the parameters(fixed/enum/client) got registered.
2020-03-11 18:56:57,540 [http-nio-8080-exec-9] [TABTHREAD1] [ ] [ SrMgmt:01.01.01] (gmt_Work_ServiceRequest.Action) INFO localhost|0:0:0:0:0:0:0:1 Admin.SrMgmt - {
"pxObjClass":"Data-Party-Person"
,"pyID":"S-40"
}
expected Log to be printed in another file:
2020-03-11 18:56:57,540 [http-nio-8080-exec-9] [TABTHREAD1] [ ] [ SrMgmt:01.01.01] (gmt_Work_ServiceRequest.Action) INFO localhost|0:0:0:0:0:0:0:1 Admin.SrMgmt - {
"pxObjClass":"Data-Party-Person"
,"pyID":"S-40"
}