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

Improper header in CsvParameterLayout

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.6.2
    • 2.7
    • Core
    • None

    Description

      The header and first record are coming in first line in case of CsvParameterLayout. This messes up the header for the first file as well as for the subsequent files. And if we use line separator as part of header, the first file seems ok but the first record in subsequent files comes out to be empty with only commas.

      Copied from the SO post:

      <?xml version="1.0" encoding="UTF-8"?>
      <Configuration status="warn" name="MyApp" packages="">
          <Properties>
              <Property name="audit-path">D:/watcher</Property>
              <Property name="file-name">audit</Property>
              <Property name="file-header">param1,param2,param3</Property>
          </Properties>
      
          <Appenders>
          <RollingFile name="auditfile"
              fileName="${audit-path}/${file-name}.tmp" filePattern="${audit-path}/${file-name}-%d{yyyy-MM-dd}-%i.csv">
              <CsvParameterLayout delimiter="," header="${file-header}">
              </CsvParameterLayout>
              <Policies>
                  <SizeBasedTriggeringPolicy size="80 B" />
              </Policies>
              <DefaultRolloverStrategy max="2"/>
          </RollingFile>
      </Appenders>
      
      <Loggers>
          <Root level="info">
              <AppenderRef ref="auditfile" />
          </Root>
      </Loggers>
      

      Attachments

        1. csv-with-line-seprator-1.csv
          0.0 kB
          Sumit Singhal
        2. csv-with-line-seprator-2.csv
          0.1 kB
          Sumit Singhal
        3. csv-without-line-separator-1.csv
          0.0 kB
          Sumit Singhal
        4. csv-without-line-separator-2.csv
          0.0 kB
          Sumit Singhal

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            sumit23 Sumit Singhal
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment