Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-2849

Event Lookup Field not applying to JSON Layout additional Property

    XMLWordPrintableJSON

Details

    • Question
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.10.0
    • None
    • Lookups
    • None

    Description

      Hi, I have a requirement where we need to change the field name of our LogEvent from `message` to `text`. In the past we've done this by creating a new custom Layout that modifies the logEvent, however I was hoping I could do this with JSON Layout lookups to the Event data.

      Here is a snippet of my log4j xml config. I've tried a few variations and the event variable is not recognized.

      <RollingFile name="APPLOGFILE" fileName="logs/app/${hostName}/application.log" filePattern="logs/app/${hostName}/app-%d{MM-dd-yyyy}-%i.log.gz"> 
      <JsonLayout complete="false" compact="true" eventEol="true" properties="true" stacktraceAsString="true"> 
         <KeyValuePair key="timestamp" value= "$${date:yyyy-MM-dd HH:mm:ss.SSS}"/>  
         <KeyValuePair key="text" value= "$${ctx:productId}"/> 
         <KeyValuePair key="text2" value= "${event:Message}"/> 
         <KeyValuePair key="text3" value= "$${event:Message}"/> 
      </JsonLayout>
      

      Context fields and date do indeed work.

       

      Please let me know if I am misusing the lookup functionality or if there is a bug.
      Also, if there is a better way to do this, that information would be helpful as well.

       

      Thanks.

      Attachments

        Activity

          People

            Unassigned Unassigned
            peterpod Peter Podniesinski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: