The way you did it with %p{ERROR=1, WARN=2, ...} looks right. If it's not
substituting properly, then you should probably file a bug.
As an aside, I added a JSON escape pattern in the upcoming release which
should be useful for your pattern. That will be %enc{...}{JSON}.
On 28 March 2017 at 13:33, Paul Mooney <[email protected]> wrote:
> To make it more clear:
>
> I want to, in log4j2.xml configuration, change the output of log level
> from Info, Debug, Trace, etc. to integers 1, 2, 3, etc.
>
> Is this possible within log4j2.xml config?
>
> Thank you
>
>
>
> On 2017-03-24 15:14 (-0500), Paul Mooney <[email protected]> wrote:
> > Hello, I am attempting to follow the example of setting a level name map
> > in the form of "level=value,level=value".
> >
> > I am trying to map string error levels to int value.
> > The purpose is to replace the string with an int for log level. This is
> > done for the logging api we use that requires an int and not a string for
> > log level.
> > I have not had success with this conversion. If someone has time to
> remark
> > on the log4j.xml file below I would appreciate it. Please let me know
> what
> > questions I may answer to help.
> >
> >
> > Thank you
> >
> >
> > ##########################################
> > <?xml version="1.0" encoding="utf-8"?>
> > <Configuration>
> > <Properties>
> > <Property name="app_name">app_name</Property>
> > </Properties>
> >
> > <!-- do not configure below this line -->
> >
> > <Appenders>
> > <RollingFile name="file"
> > fileName="${sys:mule.home}${sys:file.separator}logs${sys:
> file.separator}${app_name}.log"
> >
> > filePattern="${sys:mule.home}${sys:file.separator}logs${sys:
> file.separator}${app_name}-%i.log">
> > <PatternLayout pattern="%d [%t] %-5p %c - %m%n" />
> > <SizeBasedTriggeringPolicy size="10 MB" />
> > <DefaultRolloverStrategy max="10"/>
> > </RollingFile>
> > <JMS name="jmsQueue"
> > destinationBindingName="${sys:env}.logging"
> > factoryName="org.apache.activemq.jndi.ActiveMQInitialContextFactory"
> > factoryBindingName="ConnectionFactory"
> > providerURL="${sys:log4j.providerurl}"
> > userName="log"
> > password="log">
> > <PatternLayout
> > pattern='{"Message":"%m","LogLevel":%level{Debug=1,Info=
> 2,Warn=3,Error=4,Fatal=5,Trace=6},"Type":"middleware","
> App":"${app_name}","Env":"${sys:env}","data":{"Event_Time"
> :"%d{ISO8601}","Thread":"%t","Class":"%c"}}'/>
> > </JMS>
> > </Appenders>
> > <Loggers>
> > <!-- CXF is used heavily by Mule for web services -->
> > <AsyncLogger name="org.apache.cxf" level="WARN"/>
> >
> > <!-- Apache Commons tend to make a lot of noise which can clutter
> > the log-->
> > <AsyncLogger name="org.apache" level="WARN"/>
> >
> > <!-- Reduce startup noise -->
> > <AsyncLogger name="org.springframework.beans.factory"
> level="WARN"/>
> >
> > <!-- Mule classes -->
> > <AsyncLogger name="org.mule" level="INFO"/>
> > <AsyncLogger name="com.mulesoft" level="INFO"/>
> >
> > <!-- Reduce DM verbosity -->
> > <AsyncLogger name="org.jetel" level="WARN"/>
> > <AsyncLogger name="Tracking" level="WARN"/>
> >
> > <AsyncRoot level="INFO">
> > <AppenderRef ref="file"/>
> > <AppenderRef ref="jmsQueue"/>
> >
> > </AsyncRoot>
> > </Loggers>
> > </Configuration>
> >
> > --
> > This e-mail is: [ X] public [] private [ ] ask first
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
--
Matt Sicker <[email protected]>