Hi Chathura,

I suppose you could use the PatternLayout's regex and replacement's feature
(https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout).

It does feel like a brute-force solution though.

Perhaps a more elegant solution would be to have a notation in the
PatternLayout that expresses the use of markers on non-empty strings.

Maybe something like %wrap{%x}{[}{]}

I've had a use for something like that in the past as well.

Please create a JIRA to request a feature request. Patches welcome!

Gary

On Mon, Jun 1, 2015 at 2:06 AM, Chathura Priyankara <[email protected]
> wrote:

>
> Hi,
>
> In my log4j2 configuration file, for the pattern converters which don't
> have any value to print, the out put in the appender is an empty pair of
> square braces "[]".
>
> As an example if we have %x as a pattern converter if the log event
> doesn't have any log record in NDC it will print part of empty square
> braces.
>
> I want to know that whether is the normal behavior ? If so is there any
> way that I can set not to print square braces if it doesn't has any log
> record ?
>
> Thanks!
> Chathura.
> --
> Chathura Priyankara,
> Faculty of Information Technology,
> University of Moratuwa.
> Blog  : www.codeoncloud.blogspot.com
>



-- 
E-Mail: [email protected] | [email protected]
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Reply via email to