You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Paul Benedict <pb...@apache.org> on 2019/06/11 20:44:11 UTC

Why is my Layout header not consistently writing?

Good day.

All my File Appenders have Pattern Layouts that specify both "header" and
"footer" attributes. I use these (ex: === START and === END) to bookend
process executions  Executions happen multiple times of day, and I am
always appending to the logs.

This isn't working for me. I am experiencing the unexpected:
1) The header is *only* written if the file must be created.
2) The footer is always written.

So my log files show one header and tons of footers.

Can someone please advise?

Cheers and God bless,
Paul

Re: Why is my Layout header not consistently writing?

Posted by Paul Benedict <pb...@apache.org>.
Gary, but the reverse is happening too. The appender opens a file, may not
log anything, and still writes the footer. It's endless amounts of footers
with just one header.

Cheers and God bless,
Paul


On Tue, Jun 11, 2019 at 9:00 PM Gary Gregory <ga...@gmail.com> wrote:

> I can imagine how this bug would be a pain to fix: the appender opens a
> file, may not log anything, and before closing it, reads the end of the
> file and decides if the footer is already there. Arg.
>
> Gary
>
> On Tue, Jun 11, 2019 at 8:38 PM Ralph Goers <ra...@dslextreme.com>
> wrote:
>
> > My expectation is that a header is written when the file is first created
> > and is empty and the footer is appended when the file is closed before a
> > rollover. I suspect the first behavior is implemented but the footer is
> > being written on every close. Unfortunately it has to do that to behave
> > correctly since it has no way to know if it will ever be written to
> again.
> >
> > To be consistent the header should be written every time the file is
> > opened. But that may not be what you want.
> >
> > Ralph
> >
> > > On Jun 11, 2019, at 1:44 PM, Paul Benedict <pb...@apache.org>
> wrote:
> > >
> > > Good day.
> > >
> > > All my File Appenders have Pattern Layouts that specify both "header"
> and
> > > "footer" attributes. I use these (ex: === START and === END) to bookend
> > > process executions  Executions happen multiple times of day, and I am
> > > always appending to the logs.
> > >
> > > This isn't working for me. I am experiencing the unexpected:
> > > 1) The header is *only* written if the file must be created.
> > > 2) The footer is always written.
> > >
> > > So my log files show one header and tons of footers.
> > >
> > > Can someone please advise?
> > >
> > > Cheers and God bless,
> > > Paul
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
>

Re: Why is my Layout header not consistently writing?

Posted by Gary Gregory <ga...@gmail.com>.
I can imagine how this bug would be a pain to fix: the appender opens a
file, may not log anything, and before closing it, reads the end of the
file and decides if the footer is already there. Arg.

Gary

On Tue, Jun 11, 2019 at 8:38 PM Ralph Goers <ra...@dslextreme.com>
wrote:

> My expectation is that a header is written when the file is first created
> and is empty and the footer is appended when the file is closed before a
> rollover. I suspect the first behavior is implemented but the footer is
> being written on every close. Unfortunately it has to do that to behave
> correctly since it has no way to know if it will ever be written to again.
>
> To be consistent the header should be written every time the file is
> opened. But that may not be what you want.
>
> Ralph
>
> > On Jun 11, 2019, at 1:44 PM, Paul Benedict <pb...@apache.org> wrote:
> >
> > Good day.
> >
> > All my File Appenders have Pattern Layouts that specify both "header" and
> > "footer" attributes. I use these (ex: === START and === END) to bookend
> > process executions  Executions happen multiple times of day, and I am
> > always appending to the logs.
> >
> > This isn't working for me. I am experiencing the unexpected:
> > 1) The header is *only* written if the file must be created.
> > 2) The footer is always written.
> >
> > So my log files show one header and tons of footers.
> >
> > Can someone please advise?
> >
> > Cheers and God bless,
> > Paul
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Re: Why is my Layout header not consistently writing?

Posted by Ralph Goers <ra...@dslextreme.com>.
My expectation is that a header is written when the file is first created and is empty and the footer is appended when the file is closed before a rollover. I suspect the first behavior is implemented but the footer is being written on every close. Unfortunately it has to do that to behave correctly since it has no way to know if it will ever be written to again. 

To be consistent the header should be written every time the file is opened. But that may not be what you want.

Ralph

> On Jun 11, 2019, at 1:44 PM, Paul Benedict <pb...@apache.org> wrote:
> 
> Good day.
> 
> All my File Appenders have Pattern Layouts that specify both "header" and
> "footer" attributes. I use these (ex: === START and === END) to bookend
> process executions  Executions happen multiple times of day, and I am
> always appending to the logs.
> 
> This isn't working for me. I am experiencing the unexpected:
> 1) The header is *only* written if the file must be created.
> 2) The footer is always written.
> 
> So my log files show one header and tons of footers.
> 
> Can someone please advise?
> 
> Cheers and God bless,
> Paul



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