You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@logging.apache.org by Gary Gregory <ga...@gmail.com> on 2018/02/08 17:24:59 UTC

[log4j] NUL in log event message

In some cases I get:

2018-02-08 10:14:49,488 main WARN Unable to instantiate
org.fusesource.jansi.WindowsAnsiOutputStream due to java.io.IOException:
Could not get the screen info: T

What you do not see above is that on the console there is more after the
"T". There is a NUL character and "h e   h a n d l e   i s   i n v a l i d
." which probably contains more NUL chars since I cannot cut and copy that
string.

If I cut and paste my Eclipse console, the only text I get is the above,
not the whole console, due to the NUL char.

I am thinking that I should create a configuration for that one logger
" org.fusesource.jansi.WindowsAnsiOutputStream"
and strip out NULs. I am not sure how I can do that on a regular logger,
even less the status logger.

Do we want to take the hit to scan all status logger string messages for
NULs and replace them with SPACEs or skip them. I also am not crazy about
adding yet another option.

Thoughts?

This seems important (to me) since these kinds of messages come from the OS
and we do not have control over them.

Gary

Re: [log4j] NUL in log event message

Posted by Remko Popma <re...@gmail.com>.
Good stuff!

(Shameless plug) Every java main() method deserves http://picocli.info

> On Feb 10, 2018, at 2:47, Gary Gregory <ga...@gmail.com> wrote:
> 
> I fixed this in the one spot where we initialize Jansi and replace NULs
> with SPACEs when we log the exception's message. That's the simplest thing
> to do and leaves room for someone to investigate why JAnsi returns such a
> string since at least you can see it.
> 
> Gary
> 
>> On Thu, Feb 8, 2018 at 5:40 PM, Matt Sicker <bo...@gmail.com> wrote:
>> 
>> Could that be UTF-16 or something similar?
>> 
>>> On 8 February 2018 at 16:52, Remko Popma <re...@gmail.com> wrote:
>>> 
>>> How about stripping nulls out of any error messages coming from Jansi?
>>> 
>>> (Shameless plug) Every java main() method deserves http://picocli.info
>>> 
>>>> On Feb 9, 2018, at 5:03, Gary Gregory <ga...@gmail.com> wrote:
>>>> 
>>>> It might be a bug in JAnsi's WindowsSupport.getLastErrorMessage()
>>>> 
>>>> Gary
>>>> 
>>>> On Thu, Feb 8, 2018 at 12:42 PM, Ralph Goers <
>> ralph.goers@dslextreme.com
>>>> 
>>>> wrote:
>>>> 
>>>>> Maybe this is a silly question, but in what world is it rational to
>> have
>>>>> NULL chars in the middle of a String?
>>>>> 
>>>>> Ralph
>>>>> 
>>>>>> On Feb 8, 2018, at 10:24 AM, Gary Gregory <ga...@gmail.com>
>>>>> wrote:
>>>>>> 
>>>>>> In some cases I get:
>>>>>> 
>>>>>> 2018-02-08 10:14:49,488 main WARN Unable to instantiate
>>>>>> org.fusesource.jansi.WindowsAnsiOutputStream due to
>>> java.io.IOException:
>>>>>> Could not get the screen info: T
>>>>>> 
>>>>>> What you do not see above is that on the console there is more after
>>> the
>>>>>> "T". There is a NUL character and "h e   h a n d l e   i s   i n v a
>> l
>>> i
>>>>> d
>>>>>> ." which probably contains more NUL chars since I cannot cut and copy
>>>>> that
>>>>>> string.
>>>>>> 
>>>>>> If I cut and paste my Eclipse console, the only text I get is the
>>> above,
>>>>>> not the whole console, due to the NUL char.
>>>>>> 
>>>>>> I am thinking that I should create a configuration for that one
>> logger
>>>>>> " org.fusesource.jansi.WindowsAnsiOutputStream"
>>>>>> and strip out NULs. I am not sure how I can do that on a regular
>>> logger,
>>>>>> even less the status logger.
>>>>>> 
>>>>>> Do we want to take the hit to scan all status logger string messages
>>> for
>>>>>> NULs and replace them with SPACEs or skip them. I also am not crazy
>>> about
>>>>>> adding yet another option.
>>>>>> 
>>>>>> Thoughts?
>>>>>> 
>>>>>> This seems important (to me) since these kinds of messages come from
>>> the
>>>>> OS
>>>>>> and we do not have control over them.
>>>>>> 
>>>>>> Gary
>>>>> 
>>>>> 
>>>>> 
>>> 
>> 
>> 
>> 
>> --
>> Matt Sicker <bo...@gmail.com>
>> 

Re: [log4j] NUL in log event message

Posted by Gary Gregory <ga...@gmail.com>.
I fixed this in the one spot where we initialize Jansi and replace NULs
with SPACEs when we log the exception's message. That's the simplest thing
to do and leaves room for someone to investigate why JAnsi returns such a
string since at least you can see it.

Gary

On Thu, Feb 8, 2018 at 5:40 PM, Matt Sicker <bo...@gmail.com> wrote:

> Could that be UTF-16 or something similar?
>
> On 8 February 2018 at 16:52, Remko Popma <re...@gmail.com> wrote:
>
> > How about stripping nulls out of any error messages coming from Jansi?
> >
> > (Shameless plug) Every java main() method deserves http://picocli.info
> >
> > > On Feb 9, 2018, at 5:03, Gary Gregory <ga...@gmail.com> wrote:
> > >
> > > It might be a bug in JAnsi's WindowsSupport.getLastErrorMessage()
> > >
> > > Gary
> > >
> > > On Thu, Feb 8, 2018 at 12:42 PM, Ralph Goers <
> ralph.goers@dslextreme.com
> > >
> > > wrote:
> > >
> > >> Maybe this is a silly question, but in what world is it rational to
> have
> > >> NULL chars in the middle of a String?
> > >>
> > >> Ralph
> > >>
> > >>> On Feb 8, 2018, at 10:24 AM, Gary Gregory <ga...@gmail.com>
> > >> wrote:
> > >>>
> > >>> In some cases I get:
> > >>>
> > >>> 2018-02-08 10:14:49,488 main WARN Unable to instantiate
> > >>> org.fusesource.jansi.WindowsAnsiOutputStream due to
> > java.io.IOException:
> > >>> Could not get the screen info: T
> > >>>
> > >>> What you do not see above is that on the console there is more after
> > the
> > >>> "T". There is a NUL character and "h e   h a n d l e   i s   i n v a
> l
> > i
> > >> d
> > >>> ." which probably contains more NUL chars since I cannot cut and copy
> > >> that
> > >>> string.
> > >>>
> > >>> If I cut and paste my Eclipse console, the only text I get is the
> > above,
> > >>> not the whole console, due to the NUL char.
> > >>>
> > >>> I am thinking that I should create a configuration for that one
> logger
> > >>> " org.fusesource.jansi.WindowsAnsiOutputStream"
> > >>> and strip out NULs. I am not sure how I can do that on a regular
> > logger,
> > >>> even less the status logger.
> > >>>
> > >>> Do we want to take the hit to scan all status logger string messages
> > for
> > >>> NULs and replace them with SPACEs or skip them. I also am not crazy
> > about
> > >>> adding yet another option.
> > >>>
> > >>> Thoughts?
> > >>>
> > >>> This seems important (to me) since these kinds of messages come from
> > the
> > >> OS
> > >>> and we do not have control over them.
> > >>>
> > >>> Gary
> > >>
> > >>
> > >>
> >
>
>
>
> --
> Matt Sicker <bo...@gmail.com>
>

Re: [log4j] NUL in log event message

Posted by Matt Sicker <bo...@gmail.com>.
Could that be UTF-16 or something similar?

On 8 February 2018 at 16:52, Remko Popma <re...@gmail.com> wrote:

> How about stripping nulls out of any error messages coming from Jansi?
>
> (Shameless plug) Every java main() method deserves http://picocli.info
>
> > On Feb 9, 2018, at 5:03, Gary Gregory <ga...@gmail.com> wrote:
> >
> > It might be a bug in JAnsi's WindowsSupport.getLastErrorMessage()
> >
> > Gary
> >
> > On Thu, Feb 8, 2018 at 12:42 PM, Ralph Goers <ralph.goers@dslextreme.com
> >
> > wrote:
> >
> >> Maybe this is a silly question, but in what world is it rational to have
> >> NULL chars in the middle of a String?
> >>
> >> Ralph
> >>
> >>> On Feb 8, 2018, at 10:24 AM, Gary Gregory <ga...@gmail.com>
> >> wrote:
> >>>
> >>> In some cases I get:
> >>>
> >>> 2018-02-08 10:14:49,488 main WARN Unable to instantiate
> >>> org.fusesource.jansi.WindowsAnsiOutputStream due to
> java.io.IOException:
> >>> Could not get the screen info: T
> >>>
> >>> What you do not see above is that on the console there is more after
> the
> >>> "T". There is a NUL character and "h e   h a n d l e   i s   i n v a l
> i
> >> d
> >>> ." which probably contains more NUL chars since I cannot cut and copy
> >> that
> >>> string.
> >>>
> >>> If I cut and paste my Eclipse console, the only text I get is the
> above,
> >>> not the whole console, due to the NUL char.
> >>>
> >>> I am thinking that I should create a configuration for that one logger
> >>> " org.fusesource.jansi.WindowsAnsiOutputStream"
> >>> and strip out NULs. I am not sure how I can do that on a regular
> logger,
> >>> even less the status logger.
> >>>
> >>> Do we want to take the hit to scan all status logger string messages
> for
> >>> NULs and replace them with SPACEs or skip them. I also am not crazy
> about
> >>> adding yet another option.
> >>>
> >>> Thoughts?
> >>>
> >>> This seems important (to me) since these kinds of messages come from
> the
> >> OS
> >>> and we do not have control over them.
> >>>
> >>> Gary
> >>
> >>
> >>
>



-- 
Matt Sicker <bo...@gmail.com>

Re: [log4j] NUL in log event message

Posted by Remko Popma <re...@gmail.com>.
How about stripping nulls out of any error messages coming from Jansi?

(Shameless plug) Every java main() method deserves http://picocli.info

> On Feb 9, 2018, at 5:03, Gary Gregory <ga...@gmail.com> wrote:
> 
> It might be a bug in JAnsi's WindowsSupport.getLastErrorMessage()
> 
> Gary
> 
> On Thu, Feb 8, 2018 at 12:42 PM, Ralph Goers <ra...@dslextreme.com>
> wrote:
> 
>> Maybe this is a silly question, but in what world is it rational to have
>> NULL chars in the middle of a String?
>> 
>> Ralph
>> 
>>> On Feb 8, 2018, at 10:24 AM, Gary Gregory <ga...@gmail.com>
>> wrote:
>>> 
>>> In some cases I get:
>>> 
>>> 2018-02-08 10:14:49,488 main WARN Unable to instantiate
>>> org.fusesource.jansi.WindowsAnsiOutputStream due to java.io.IOException:
>>> Could not get the screen info: T
>>> 
>>> What you do not see above is that on the console there is more after the
>>> "T". There is a NUL character and "h e   h a n d l e   i s   i n v a l i
>> d
>>> ." which probably contains more NUL chars since I cannot cut and copy
>> that
>>> string.
>>> 
>>> If I cut and paste my Eclipse console, the only text I get is the above,
>>> not the whole console, due to the NUL char.
>>> 
>>> I am thinking that I should create a configuration for that one logger
>>> " org.fusesource.jansi.WindowsAnsiOutputStream"
>>> and strip out NULs. I am not sure how I can do that on a regular logger,
>>> even less the status logger.
>>> 
>>> Do we want to take the hit to scan all status logger string messages for
>>> NULs and replace them with SPACEs or skip them. I also am not crazy about
>>> adding yet another option.
>>> 
>>> Thoughts?
>>> 
>>> This seems important (to me) since these kinds of messages come from the
>> OS
>>> and we do not have control over them.
>>> 
>>> Gary
>> 
>> 
>> 

Re: [log4j] NUL in log event message

Posted by Gary Gregory <ga...@gmail.com>.
It might be a bug in JAnsi's WindowsSupport.getLastErrorMessage()

Gary

On Thu, Feb 8, 2018 at 12:42 PM, Ralph Goers <ra...@dslextreme.com>
wrote:

> Maybe this is a silly question, but in what world is it rational to have
> NULL chars in the middle of a String?
>
> Ralph
>
> > On Feb 8, 2018, at 10:24 AM, Gary Gregory <ga...@gmail.com>
> wrote:
> >
> > In some cases I get:
> >
> > 2018-02-08 10:14:49,488 main WARN Unable to instantiate
> > org.fusesource.jansi.WindowsAnsiOutputStream due to java.io.IOException:
> > Could not get the screen info: T
> >
> > What you do not see above is that on the console there is more after the
> > "T". There is a NUL character and "h e   h a n d l e   i s   i n v a l i
> d
> > ." which probably contains more NUL chars since I cannot cut and copy
> that
> > string.
> >
> > If I cut and paste my Eclipse console, the only text I get is the above,
> > not the whole console, due to the NUL char.
> >
> > I am thinking that I should create a configuration for that one logger
> > " org.fusesource.jansi.WindowsAnsiOutputStream"
> > and strip out NULs. I am not sure how I can do that on a regular logger,
> > even less the status logger.
> >
> > Do we want to take the hit to scan all status logger string messages for
> > NULs and replace them with SPACEs or skip them. I also am not crazy about
> > adding yet another option.
> >
> > Thoughts?
> >
> > This seems important (to me) since these kinds of messages come from the
> OS
> > and we do not have control over them.
> >
> > Gary
>
>
>

Re: [log4j] NUL in log event message

Posted by Ralph Goers <ra...@dslextreme.com>.
Maybe this is a silly question, but in what world is it rational to have NULL chars in the middle of a String?

Ralph

> On Feb 8, 2018, at 10:24 AM, Gary Gregory <ga...@gmail.com> wrote:
> 
> In some cases I get:
> 
> 2018-02-08 10:14:49,488 main WARN Unable to instantiate
> org.fusesource.jansi.WindowsAnsiOutputStream due to java.io.IOException:
> Could not get the screen info: T
> 
> What you do not see above is that on the console there is more after the
> "T". There is a NUL character and "h e   h a n d l e   i s   i n v a l i d
> ." which probably contains more NUL chars since I cannot cut and copy that
> string.
> 
> If I cut and paste my Eclipse console, the only text I get is the above,
> not the whole console, due to the NUL char.
> 
> I am thinking that I should create a configuration for that one logger
> " org.fusesource.jansi.WindowsAnsiOutputStream"
> and strip out NULs. I am not sure how I can do that on a regular logger,
> even less the status logger.
> 
> Do we want to take the hit to scan all status logger string messages for
> NULs and replace them with SPACEs or skip them. I also am not crazy about
> adding yet another option.
> 
> Thoughts?
> 
> This seems important (to me) since these kinds of messages come from the OS
> and we do not have control over them.
> 
> Gary