logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: XMLLayout indents, but not the first child tag (<Event>)
Date Tue, 19 Apr 2016 15:00:55 GMT
Hi,

Does the build pass when you run 'mvn clean test'?

Does your patch affect the other Jackson-based layouts (JSON and YAML)?
Hopefully not.

I think that if all the tests pass and the other layouts are not affected,
you should create a JIRA and attach your patch. Even if not, you can still
create a JIRA and attach a WIP patch.

BTW, make sure your patch has unit tests so we can make sure this change
works and does not get undone in the future.

Gary

On Tue, Apr 19, 2016 at 7:24 AM, Kamal Mettananda <lkamal@gmail.com> wrote:

> Hi Gary
>
> Not really, the number of blank lines are exactly the same in both cases,
> but the new one has the indentation also fixed. Please see below summarized
> version of the two files (both having two *BLANK LINE*s, but it's location
> is different).
>
> *Current Xml file*
>
> <?xml...?>
> <Events ...>
> <Event .../>
> *BLANK LINE*
> <Event .../>
> *BLANK LINE*
> </Events>
>
> *New Xml file*
>
> <?xml...?>
> <Events ...>
> *BLANK LINE*
>   <Event .../>
> *BLANK LINE*
>   <Event .../>
> </Events>
>
> However if this does not still fit, still please let me know.
>
> If it sounds OK, I can create the Jira with patch so that the team can look
> into and decide whether to proceed with it or not.
>
> Thanks
>
> -----------------
> www.digizol.com
>
> On Tue, Apr 19, 2016 at 2:58 AM Gary Gregory <garydgregory@gmail.com>
> wrote:
>
> > Hi, yes they way to go is to create a JIRA and then _attach_ your patch
> in
> > united diff format to the JIRA issue.
> >
> > There is more blank lines with this right? That's not great but submit
> your
> > patch and let's see what happens.
> >
> > Gary
> >
> > On Mon, Apr 18, 2016 at 10:55 AM, Kamal Mettananda <lkamal@gmail.com>
> > wrote:
> >
> > > Hi all
> > >
> > > Already there is one blank line between any two <Event> blocks within
> the
> > > XML file; but that is because of the way the existing PrettyPrinter
> class
> > > behaves. However I too feel it is not good to have multiple blank lines
> > > between <Event> blocks.
> > >
> > > I did a slight change to the way the PrettyPrinter works; and got the
> XML
> > > printed as follows (only with one blank line between any two <Event>
> > blocks
> > > - most similar to current output).
> > >
> > > *Current Xml file*
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <Events xmlns="http://logging.apache.org/log4j/2.0/events">
> > > <Event xmlns="http://logging.apache.org/log4j/2.0/events"
> > > timeMillis="1460974404123" thread="main" level="INFO"
> > > loggerName="com.foo.Bar" endOfBatch="true"
> > > loggerFqcn="org.apache.logging.log4j.spi.AbstractLogger" threadId="11"
> > > threadPriority="5">
> > >   <Message>Message flushed with immediate flush=false</Message>
> > > </Event>
> > >
> > > <Event xmlns="http://logging.apache.org/log4j/2.0/events"
> > > timeMillis="1460974404133" thread="main" level="INFO"
> > > loggerName="com.foo.Bar" endOfBatch="true"
> > > loggerFqcn="org.apache.logging.log4j.spi.AbstractLogger" threadId="11"
> > > threadPriority="5">
> > >   <Message>Message flushed with immediate flush=false</Message>
> > > </Event>
> > >
> > > </Events>
> > >
> > > *New Xml file*
> > > <?xml version="1.0" encoding="UTF-8"?>^M
> > > <Events xmlns="http://logging.apache.org/log4j/2.0/events">
> > >
> > >   <Event xmlns="http://logging.apache.org/log4j/2.0/events"
> > > timeMillis="1460973958301" thread="main" level="INFO"
> > > loggerName="com.foo.Bar" endOfBatch="true"
> > > loggerFqcn="org.apache.logging.log4j.spi.AbstractLogger" threadId="11"
> > > threadPriority="5">
> > >     <Message>Message flushed with immediate flush=false</Message>
> > >   </Event>
> > >
> > >   <Event xmlns="http://logging.apache.org/log4j/2.0/events"
> > > timeMillis="1460973958323" thread="main" level="INFO"
> > > loggerName="com.foo.Bar" endOfBatch="true"
> > > loggerFqcn="org.apache.logging.log4j.spi.AbstractLogger" threadId="11"
> > > threadPriority="5">
> > >     <Message>Message flushed with immediate flush=false</Message>
> > >   </Event>
> > > </Events>
> > >
> > > Please have a look at that and let me know whether this seems OK. If
> that
> > > seems correct, I can update the test cases as well and share a patch.
> > >
> > > As I am new here, please let me know whether I should create a Jira
> > ticket
> > > <https://issues.apache.org/jira/browse/log4j2/> and attach the patch
> or
> > > attach it into an email?
> > >
> > > Thanks
> > >
> > > ------------------
> > > www.digizol.com
> > >
> > >
> > > On Mon, Apr 18, 2016 at 3:36 AM Ralph Goers <
> ralph.goers@dslextreme.com>
> > > wrote:
> > >
> > > > I certainly wouldn’t expect to see any blank lines.
> > > >
> > > > Ralph
> > > >
> > > > > On Apr 17, 2016, at 2:42 PM, Gary Gregory <garydgregory@gmail.com>
> > > > wrote:
> > > > >
> > > > > IMO there should not be any blank lines, even in non-compact mode.
> > > > >
> > > > > Thoughts from others?
> > > > > Gary
> > > > > On Apr 17, 2016 1:34 PM, "Kamal Mettananda" <lkamal@gmail.com>
> > wrote:
> > > > >
> > > > >> Hi Gary & all
> > > > >>
> > > > >> I looked at the code and did some modifications around the
> > > > >> jackson-dataformat-xml based formatting area. As per current
> > > > >> implementation, there is one additional line between each ending
> > > > </Event>
> > > > >> tag and next new <Event> tag; but with this fix, there
will be
> > another
> > > > >> additional new line between those as shown below.
> > > > >>
> > > > >> I am not sure whether that is OK, so please let me know your
> > thoughts
> > > on
> > > > >> this result.
> > > > >>
> > > > >> *Current XML file*
> > > > >> <?xml version="1.0" encoding="UTF-8"?>^M
> > > > >> <Events xmlns="http://logging.apache.org/log4j/2.0/events">
> > > > >> <Event xmlns="http://logging.apache.org/log4j/2.0/events"
> > > > >> timeMillis="1460924567162" thread="main" level="INFO"
> > > > >> loggerName="com.foo.Bar" endOfBatch="true"
> > > > >> loggerFqcn="org.apache.logging.log4j.spi.AbstractLogger"
> > threadId="11"
> > > > >> threadPriority="5">
> > > > >>  <Message>Message flushed with immediate flush=false</Message>
> > > > >> </Event>
> > > > >>
> > > > >> <Event xmlns="http://logging.apache.org/log4j/2.0/events"
> > > > >> timeMillis="1460924567162" thread="main" level="INFO"
> > > > >> loggerName="com.foo.Bar" endOfBatch="true"
> > > > >> loggerFqcn="org.apache.logging.log4j.spi.AbstractLogger"
> > threadId="11"
> > > > >> threadPriority="5">
> > > > >>  <Message>Message flushed with immediate flush=false</Message>
> > > > >> </Event>
> > > > >>
> > > > >> </Events>
> > > > >>
> > > > >> *New XML file*
> > > > >>
> > > > >> <?xml version="1.0" encoding="UTF-8"?>
> > > > >> <Events xmlns="http://logging.apache.org/log4j/2.0/events">
> > > > >>
> > > > >>  <Event xmlns="http://logging.apache.org/log4j/2.0/events"
> > > > >> timeMillis="1460924457009" thread="main" level="INFO"
> > > > >> loggerName="com.foo.Bar" endOfBatch="false"
> > > > >> loggerFqcn="org.apache.logging.log4j.spi.AbstractLogger"
> > threadId="11"
> > > > >> threadPriority="5">
> > > > >>    <Message>Message flushed with immediate flush=false</Message>
> > > > >>  </Event>
> > > > >>
> > > > >>
> > > > >>  <Event xmlns="http://logging.apache.org/log4j/2.0/events"
> > > > >> timeMillis="1460924457010" thread="main" level="INFO"
> > > > >> loggerName="com.foo.Bar" endOfBatch="true"
> > > > >> loggerFqcn="org.apache.logging.log4j.spi.AbstractLogger"
> > threadId="11"
> > > > >> threadPriority="5">
> > > > >>    <Message>Message flushed with immediate flush=false</Message>
> > > > >>  </Event>
> > > > >>
> > > > >> </Events>
> > > > >>
> > > > >> I can share the code as a patch in case this approach is OK.
> > > > >>
> > > > >> Thanks
> > > > >>
> > > > >> ---------------------------
> > > > >> www.digizol.com
> > > > >>
> > > > >> On Mon, Apr 11, 2016 at 11:19 PM Gary Gregory <
> > garydgregory@gmail.com
> > > >
> > > > >> wrote:
> > > > >>
> > > > >>> Feel free to submit a unit test and patch.
> > > > >>>
> > > > >>> Gary
> > > > >>>
> > > > >>> On Mon, Mar 28, 2016 at 12:00 PM, Kamal Mettananda <
> > lkamal@gmail.com
> > > >
> > > > >>> wrote:
> > > > >>>
> > > > >>>> Hi all
> > > > >>>>
> > > > >>>> I am using log4j 2.5 to print the logs via XMLLayout.
I have set
> > > > >>>> compact="true", hence the new line and indents of sub
tags work
> > > > >>> correctly.
> > > > >>>> However I have noticed that the first child tag is not
indented
> > > > >>> corrected.
> > > > >>>> Following is such a sample where <Events> and <Event>
are at the
> > > same
> > > > >>>> indent level (0 indent). I do think this is a formatting
issue
> in
> > > the
> > > > >>> code
> > > > >>>> rather than expected behavior; but I might be wrong?
> > > > >>>>
> > > > >>>> <?xml version="1.0" encoding="UTF-8"?>
> > > > >>>> <Events xmlns="http://logging.apache.org/log4j/2.0/events">
> > > > >>>> <Event xmlns="http://logging.apache.org/log4j/2.0/events"
> > > > >>>> timeMillis="1459191034362" thread="main" level="INFO"
> > > > >>>> loggerName="org.logging.learn.log4j.Main" endOfBatch="false"
> > > > >>>> loggerFqcn="org.apache.logging.log4j.spi.AbstractLogger">
> > > > >>>>  <Message>6 + 4 = 10</Message>
> > > > >>>> </Event>
> > > > >>>>
> > > > >>>> <Event xmlns="http://logging.apache.org/log4j/2.0/events"
> > > > >>>> timeMillis="1459191034457" thread="main" level="INFO"
> > > > >>>> loggerName="org.logging.learn.log4j.Main" endOfBatch="false"
> > > > >>>> loggerFqcn="org.apache.logging.log4j.spi.AbstractLogger">
> > > > >>>>  <Message>6 - 4 = 2</Message>
> > > > >>>> </Event>
> > > > >>>>
> > > > >>>> </Events>
> > > > >>>>
> > > > >>>> Thanks
> > > > >>>>
> > > > >>>
> > > > >>>
> > > > >>>
> > > > >>> --
> > > > >>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> > > > >>> 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
> > > > >>>
> > > > >>
> > > >
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > > > For additional commands, e-mail: log4j-user-help@logging.apache.org
> > > >
> > > >
> > >
> >
> >
> >
> > --
> > E-Mail: garydgregory@gmail.com | ggregory@apache.org
> > 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
> >
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message