You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Sumit Singhal (JIRA)" <ji...@apache.org> on 2016/08/08 09:21:20 UTC

[jira] [Updated] (LOG4J2-1502) CsvParameterLayout is inserting NUL character if data starts with {, (, [ or "

     [ https://issues.apache.org/jira/browse/LOG4J2-1502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sumit Singhal updated LOG4J2-1502:
----------------------------------
    Description: 
I am using CsvParameterLayout to generate a CSV file out of log4j2. One of the column is a JSON string. Following is the logger method I am using:

{code:java}
logger.info("log:{}",json);
{code}

Following is the JSON string:

{code:json}
{"id":10,"name":"sumit"}
{code}

And following is the string which is getting printed in CSV output file:

 NUL{"id":10,"name":"sumit"}NUL

The NUL character is the \x00 character. When I open the file in notepad++, then only this character appears. In notepad it shows as space. This poses a problem in CSV processing module.

If there is some alphabet before {, then the output in CSV is fine. It seems as if log4j is escaping '{' with a NUL character. It is happening if the string starts with {, (, [, ' or ".


  was:
I am using CsvParameterLayout to generate a CSV file out of log4j2. One of the column is a JSON string. Following is the logger method I am using:

logger.info("log:{}",json);

Following is the JSON string:

{"id":10,"name":"sumit"}

And following is the string which is getting printed in CSV output file:

 NUL{"id":10,"name":"sumit"}NUL

The NUL character is the \x00 character. When I open the file in notepad++, then only this character appears. In notepad it shows as space. This poses a problem in CSV processing module.

If there is some alphabet before {, then the output in CSV is fine. It seems as if log4j is escaping '{' with a NUL character. It is happening if the string starts with {, (, [, ' or ".



> CsvParameterLayout is inserting NUL character if data starts with {, (, [ or "
> ------------------------------------------------------------------------------
>
>                 Key: LOG4J2-1502
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1502
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Layouts
>    Affects Versions: 2.6.2
>            Reporter: Sumit Singhal
>
> I am using CsvParameterLayout to generate a CSV file out of log4j2. One of the column is a JSON string. Following is the logger method I am using:
> {code:java}
> logger.info("log:{}",json);
> {code}
> Following is the JSON string:
> {code:json}
> {"id":10,"name":"sumit"}
> {code}
> And following is the string which is getting printed in CSV output file:
>  NUL{"id":10,"name":"sumit"}NUL
> The NUL character is the \x00 character. When I open the file in notepad++, then only this character appears. In notepad it shows as space. This poses a problem in CSV processing module.
> If there is some alphabet before {, then the output in CSV is fine. It seems as if log4j is escaping '{' with a NUL character. It is happening if the string starts with {, (, [, ' or ".



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org