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 Gary Gregory <ga...@gmail.com> on 2014/05/19 21:47:23 UTC

Consuming logs

I get logs from users that are files, which is nice.

I'd like the log to have a line that shows the conversion pattern used to
create the log events.

This would let me create a nice color filter in our tools.

Yes, I know users could use some kind of structured appender in addition to
a log file, but they won't for my convenience...

So I wonder if we could have setting for this? Our tools create the config,
so we could turn it on no matter what conversion pattern they use.

Gary

-- 
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

Re: Consuming logs

Posted by Gary Gregory <ga...@gmail.com>.
On Tue, May 20, 2014 at 4:56 PM, Ralph Goers <ra...@dslextreme.com>wrote:

> Unfortunately I am at work and can’t give this my full attention. I will
> try to find some time tonight to figure something out.
>

Roger that. I'll pause on this one.

Gary


>
> Ralph
>
> On May 20, 2014, at 1:40 PM, Gary Gregory <ga...@gmail.com> wrote:
>
> How about this hack for PatterLayout:
>
>     @Override
>     public byte[] getHeader() {
>         byte[] myHeader = super.getHeader();
>         final Charset cs = getCharset();
>         String strHeader = "# Conversion pattern: " +
> this.conversionPattern;
>         if (myHeader != null) {
>             strHeader = config.getStrSubstitutor().replace(new
> String(myHeader, cs)) + Constants.LINE_SEPARATOR + strHeader;
>         }
>         return strHeader.getBytes(cs);
>     }
>
> ?
>
> Gary
>
>
> On Tue, May 20, 2014 at 3:34 PM, Gary Gregory <ga...@gmail.com>wrote:
>
>> On Tue, May 20, 2014 at 2:46 PM, Ralph Goers <ra...@dslextreme.com>wrote:
>>
>>> You could implement a lookup but both the syntax of how it would be
>>> specified and how it would work would be odd.  Or you could implement a
>>> PatternConverter while would allow you do invoke PatternParser.parse, but
>>> that would also be awkward as they typically think they are working with a
>>> LogEvent.
>>>
>>
>> So, two odd possible solutions, not a great smell.
>>
>> How do you (or anyone else ;-) see this done well?
>>
>> Gary
>>
>>
>>> Note that what you have below - %pattern - doesn’t match with how
>>> Lookups work.
>>>
>>
>> Check, that was just a placeholder string.
>>
>> Gary
>>
>>>
>>> Ralph
>>>
>>> On May 20, 2014, at 10:48 AM, Gary Gregory <ga...@gmail.com>
>>> wrote:
>>>
>>> I was thinking of experimenting with this in PatternLayout:
>>>
>>>     @Override
>>>     public byte[] getHeader() {
>>>         byte [] header = super.getHeader();
>>>         if (header != null) {
>>>             return config.getStrSubstitutor().replace(new String(header,
>>> getCharset())).getBytes(getCharset());
>>>         }
>>>         return header;
>>>     }
>>>
>>> Why not support this with a marker like %pattern (of whatever). But how
>>> can we tell the config's StrSubstitor about this layout's pattern string?
>>>
>>> In the ctor we could do:
>>>
>>> this.config = config;
>>> this.config.getStrSubstitutor().getStrLookup().put("pattern", pattern);
>>>
>>> But StrLookup does not support put(String, String) of course...
>>>
>>> What would be a supported way to do this or do we need to tweak things a
>>> bit?
>>>
>>> Gary
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Tue, May 20, 2014 at 9:27 AM, Gary Gregory <ga...@gmail.com>wrote:
>>>
>>>> For best usability I am wondering if this should be an option, but if
>>>> it is it should be on by default. Thoughts?
>>>>
>>>> Gary
>>>>
>>>>
>>>> On Mon, May 19, 2014 at 9:42 PM, Gary Gregory <ga...@gmail.com>wrote:
>>>>
>>>>> On Mon, May 19, 2014 at 9:37 PM, Ralph Goers <
>>>>> ralph.goers@dslextreme.com> wrote:
>>>>>
>>>>>> It sounds like you want that in the header of the file?  That sounds
>>>>>> like an extension of what PatternLayout currently does. You would just want
>>>>>> to set the header to include the pattern.  Of course, this doesn’t apply to
>>>>>> Appenders that use some other layout.
>>>>>>
>>>>>
>>>>> Yes in the header. whatever a header means for a text file appender
>>>>> for example, maybe it is a "comment" like a comment in a property file: #
>>>>> my format.
>>>>>
>>>>> This only needs to apply to "unstructured" layouts, which are all text
>>>>> based layouts, like the File and Console, I think these all share a
>>>>> streaming super class/manager. For a database appender and other structured
>>>>> layouts (XML, JSON, and so on), this does not make sense.
>>>>>
>>>>> Gary
>>>>>
>>>>> Gary
>>>>>
>>>>>>
>>>>>> Ralph
>>>>>>
>>>>>> On May 19, 2014, at 12:47 PM, Gary Gregory <ga...@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>> I get logs from users that are files, which is nice.
>>>>>>
>>>>>> I'd like the log to have a line that shows the conversion pattern
>>>>>> used to create the log events.
>>>>>>
>>>>>> This would let me create a nice color filter in our tools.
>>>>>>
>>>>>> Yes, I know users could use some kind of structured appender in
>>>>>> addition to a log file, but they won't for my convenience...
>>>>>>
>>>>>> So I wonder if we could have setting for this? Our tools create the
>>>>>> config, so we could turn it on no matter what conversion pattern they use.
>>>>>>
>>>>>> Gary
>>>>>>
>>>>>> --
>>>>>> 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
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> 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
>>>
>>>
>>>
>>
>>
>> --
>> 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
>
>
>


-- 
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

Re: Consuming logs

Posted by Ralph Goers <ra...@dslextreme.com>.
Unfortunately I am at work and can’t give this my full attention. I will try to find some time tonight to figure something out.

Ralph

On May 20, 2014, at 1:40 PM, Gary Gregory <ga...@gmail.com> wrote:

> How about this hack for PatterLayout:
> 
>     @Override
>     public byte[] getHeader() {
>         byte[] myHeader = super.getHeader();
>         final Charset cs = getCharset();
>         String strHeader = "# Conversion pattern: " + this.conversionPattern;
>         if (myHeader != null) {
>             strHeader = config.getStrSubstitutor().replace(new String(myHeader, cs)) + Constants.LINE_SEPARATOR + strHeader;
>         }
>         return strHeader.getBytes(cs);
>     }
> 
> ?
> 
> Gary
> 
> 
> On Tue, May 20, 2014 at 3:34 PM, Gary Gregory <ga...@gmail.com> wrote:
> On Tue, May 20, 2014 at 2:46 PM, Ralph Goers <ra...@dslextreme.com> wrote:
> You could implement a lookup but both the syntax of how it would be specified and how it would work would be odd.  Or you could implement a PatternConverter while would allow you do invoke PatternParser.parse, but that would also be awkward as they typically think they are working with a LogEvent.  
> 
> So, two odd possible solutions, not a great smell. 
> 
> How do you (or anyone else ;-) see this done well?
> 
> Gary
> 
> 
> Note that what you have below - %pattern - doesn’t match with how Lookups work.
> 
> Check, that was just a placeholder string.
> 
> Gary 
> 
> Ralph
> 
> On May 20, 2014, at 10:48 AM, Gary Gregory <ga...@gmail.com> wrote:
> 
>> I was thinking of experimenting with this in PatternLayout:
>> 
>>     @Override
>>     public byte[] getHeader() {
>>         byte [] header = super.getHeader();
>>         if (header != null) {
>>             return config.getStrSubstitutor().replace(new String(header, getCharset())).getBytes(getCharset());
>>         }
>>         return header;
>>     }
>> 
>> Why not support this with a marker like %pattern (of whatever). But how can we tell the config's StrSubstitor about this layout's pattern string?
>> 
>> In the ctor we could do:
>> 
>> this.config = config;
>> this.config.getStrSubstitutor().getStrLookup().put("pattern", pattern);
>> 
>> But StrLookup does not support put(String, String) of course...
>> 
>> What would be a supported way to do this or do we need to tweak things a bit?
>> 
>> Gary
>> 
>> 
>> 
>> 
>> 
>> 
>> On Tue, May 20, 2014 at 9:27 AM, Gary Gregory <ga...@gmail.com> wrote:
>> For best usability I am wondering if this should be an option, but if it is it should be on by default. Thoughts?
>> 
>> Gary
>> 
>> 
>> On Mon, May 19, 2014 at 9:42 PM, Gary Gregory <ga...@gmail.com> wrote:
>> On Mon, May 19, 2014 at 9:37 PM, Ralph Goers <ra...@dslextreme.com> wrote:
>> It sounds like you want that in the header of the file?  That sounds like an extension of what PatternLayout currently does. You would just want to set the header to include the pattern.  Of course, this doesn’t apply to Appenders that use some other layout.
>> 
>> Yes in the header. whatever a header means for a text file appender for example, maybe it is a "comment" like a comment in a property file: # my format.
>> 
>> This only needs to apply to "unstructured" layouts, which are all text based layouts, like the File and Console, I think these all share a streaming super class/manager. For a database appender and other structured layouts (XML, JSON, and so on), this does not make sense.
>> 
>> Gary
>> 
>> Gary
>> 
>> Ralph
>> 
>> On May 19, 2014, at 12:47 PM, Gary Gregory <ga...@gmail.com> wrote:
>> 
>>> I get logs from users that are files, which is nice.
>>> 
>>> I'd like the log to have a line that shows the conversion pattern used to create the log events.
>>> 
>>> This would let me create a nice color filter in our tools.
>>> 
>>> Yes, I know users could use some kind of structured appender in addition to a log file, but they won't for my convenience...
>>> 
>>> So I wonder if we could have setting for this? Our tools create the config, so we could turn it on no matter what conversion pattern they use.
>>> 
>>> Gary
>>> 
>>> -- 
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>>> Java Persistence with Hibernate, Second Edition
>>> JUnit in Action, Second Edition
>>> Spring Batch in Action
>>> 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
>> JUnit in Action, Second Edition
>> Spring Batch in Action
>> 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
>> JUnit in Action, Second Edition
>> Spring Batch in Action
>> 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
>> JUnit in Action, Second Edition
>> Spring Batch in Action
>> 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
> JUnit in Action, Second Edition
> Spring Batch in Action
> 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
> JUnit in Action, Second Edition
> Spring Batch in Action
> Blog: http://garygregory.wordpress.com 
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory


Re: Consuming logs

Posted by Gary Gregory <ga...@gmail.com>.
If it's a CSV, I know the format ;-)

Gary


On Tue, May 20, 2014 at 4:42 PM, Paul Benedict <pb...@apache.org> wrote:

> Gary, you could make it CSV and use all your hard work in commons csv :-)
>
>
> Cheers,
> Paul
>
>
> On Tue, May 20, 2014 at 3:40 PM, Gary Gregory <ga...@gmail.com>wrote:
>
>> How about this hack for PatterLayout:
>>
>>     @Override
>>     public byte[] getHeader() {
>>         byte[] myHeader = super.getHeader();
>>         final Charset cs = getCharset();
>>         String strHeader = "# Conversion pattern: " +
>> this.conversionPattern;
>>         if (myHeader != null) {
>>             strHeader = config.getStrSubstitutor().replace(new
>> String(myHeader, cs)) + Constants.LINE_SEPARATOR + strHeader;
>>         }
>>         return strHeader.getBytes(cs);
>>     }
>>
>> ?
>>
>> Gary
>>
>>
>> On Tue, May 20, 2014 at 3:34 PM, Gary Gregory <ga...@gmail.com>wrote:
>>
>>> On Tue, May 20, 2014 at 2:46 PM, Ralph Goers <ralph.goers@dslextreme.com
>>> > wrote:
>>>
>>>> You could implement a lookup but both the syntax of how it would be
>>>> specified and how it would work would be odd.  Or you could implement a
>>>> PatternConverter while would allow you do invoke PatternParser.parse, but
>>>> that would also be awkward as they typically think they are working with a
>>>> LogEvent.
>>>>
>>>
>>> So, two odd possible solutions, not a great smell.
>>>
>>> How do you (or anyone else ;-) see this done well?
>>>
>>> Gary
>>>
>>>
>>>> Note that what you have below - %pattern - doesn’t match with how
>>>> Lookups work.
>>>>
>>>
>>> Check, that was just a placeholder string.
>>>
>>> Gary
>>>
>>>>
>>>> Ralph
>>>>
>>>> On May 20, 2014, at 10:48 AM, Gary Gregory <ga...@gmail.com>
>>>> wrote:
>>>>
>>>> I was thinking of experimenting with this in PatternLayout:
>>>>
>>>>     @Override
>>>>     public byte[] getHeader() {
>>>>         byte [] header = super.getHeader();
>>>>         if (header != null) {
>>>>             return config.getStrSubstitutor().replace(new
>>>> String(header, getCharset())).getBytes(getCharset());
>>>>         }
>>>>         return header;
>>>>     }
>>>>
>>>> Why not support this with a marker like %pattern (of whatever). But how
>>>> can we tell the config's StrSubstitor about this layout's pattern string?
>>>>
>>>> In the ctor we could do:
>>>>
>>>> this.config = config;
>>>> this.config.getStrSubstitutor().getStrLookup().put("pattern", pattern);
>>>>
>>>> But StrLookup does not support put(String, String) of course...
>>>>
>>>> What would be a supported way to do this or do we need to tweak things
>>>> a bit?
>>>>
>>>> Gary
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Tue, May 20, 2014 at 9:27 AM, Gary Gregory <ga...@gmail.com>wrote:
>>>>
>>>>> For best usability I am wondering if this should be an option, but if
>>>>> it is it should be on by default. Thoughts?
>>>>>
>>>>> Gary
>>>>>
>>>>>
>>>>> On Mon, May 19, 2014 at 9:42 PM, Gary Gregory <ga...@gmail.com>wrote:
>>>>>
>>>>>> On Mon, May 19, 2014 at 9:37 PM, Ralph Goers <
>>>>>> ralph.goers@dslextreme.com> wrote:
>>>>>>
>>>>>>> It sounds like you want that in the header of the file?  That sounds
>>>>>>> like an extension of what PatternLayout currently does. You would just want
>>>>>>> to set the header to include the pattern.  Of course, this doesn’t apply to
>>>>>>> Appenders that use some other layout.
>>>>>>>
>>>>>>
>>>>>> Yes in the header. whatever a header means for a text file appender
>>>>>> for example, maybe it is a "comment" like a comment in a property file: #
>>>>>> my format.
>>>>>>
>>>>>> This only needs to apply to "unstructured" layouts, which are all
>>>>>> text based layouts, like the File and Console, I think these all share a
>>>>>> streaming super class/manager. For a database appender and other structured
>>>>>> layouts (XML, JSON, and so on), this does not make sense.
>>>>>>
>>>>>> Gary
>>>>>>
>>>>>> Gary
>>>>>>
>>>>>>>
>>>>>>> Ralph
>>>>>>>
>>>>>>> On May 19, 2014, at 12:47 PM, Gary Gregory <ga...@gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>> I get logs from users that are files, which is nice.
>>>>>>>
>>>>>>> I'd like the log to have a line that shows the conversion pattern
>>>>>>> used to create the log events.
>>>>>>>
>>>>>>> This would let me create a nice color filter in our tools.
>>>>>>>
>>>>>>> Yes, I know users could use some kind of structured appender in
>>>>>>> addition to a log file, but they won't for my convenience...
>>>>>>>
>>>>>>> So I wonder if we could have setting for this? Our tools create the
>>>>>>> config, so we could turn it on no matter what conversion pattern they use.
>>>>>>>
>>>>>>> Gary
>>>>>>>
>>>>>>> --
>>>>>>> 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
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> 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
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> 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
>>
>
>


-- 
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

Re: Consuming logs

Posted by Paul Benedict <pb...@apache.org>.
Gary, you could make it CSV and use all your hard work in commons csv :-)


Cheers,
Paul


On Tue, May 20, 2014 at 3:40 PM, Gary Gregory <ga...@gmail.com>wrote:

> How about this hack for PatterLayout:
>
>     @Override
>     public byte[] getHeader() {
>         byte[] myHeader = super.getHeader();
>         final Charset cs = getCharset();
>         String strHeader = "# Conversion pattern: " +
> this.conversionPattern;
>         if (myHeader != null) {
>             strHeader = config.getStrSubstitutor().replace(new
> String(myHeader, cs)) + Constants.LINE_SEPARATOR + strHeader;
>         }
>         return strHeader.getBytes(cs);
>     }
>
> ?
>
> Gary
>
>
> On Tue, May 20, 2014 at 3:34 PM, Gary Gregory <ga...@gmail.com>wrote:
>
>> On Tue, May 20, 2014 at 2:46 PM, Ralph Goers <ra...@dslextreme.com>wrote:
>>
>>> You could implement a lookup but both the syntax of how it would be
>>> specified and how it would work would be odd.  Or you could implement a
>>> PatternConverter while would allow you do invoke PatternParser.parse, but
>>> that would also be awkward as they typically think they are working with a
>>> LogEvent.
>>>
>>
>> So, two odd possible solutions, not a great smell.
>>
>> How do you (or anyone else ;-) see this done well?
>>
>> Gary
>>
>>
>>> Note that what you have below - %pattern - doesn’t match with how
>>> Lookups work.
>>>
>>
>> Check, that was just a placeholder string.
>>
>> Gary
>>
>>>
>>> Ralph
>>>
>>> On May 20, 2014, at 10:48 AM, Gary Gregory <ga...@gmail.com>
>>> wrote:
>>>
>>> I was thinking of experimenting with this in PatternLayout:
>>>
>>>     @Override
>>>     public byte[] getHeader() {
>>>         byte [] header = super.getHeader();
>>>         if (header != null) {
>>>             return config.getStrSubstitutor().replace(new String(header,
>>> getCharset())).getBytes(getCharset());
>>>         }
>>>         return header;
>>>     }
>>>
>>> Why not support this with a marker like %pattern (of whatever). But how
>>> can we tell the config's StrSubstitor about this layout's pattern string?
>>>
>>> In the ctor we could do:
>>>
>>> this.config = config;
>>> this.config.getStrSubstitutor().getStrLookup().put("pattern", pattern);
>>>
>>> But StrLookup does not support put(String, String) of course...
>>>
>>> What would be a supported way to do this or do we need to tweak things a
>>> bit?
>>>
>>> Gary
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Tue, May 20, 2014 at 9:27 AM, Gary Gregory <ga...@gmail.com>wrote:
>>>
>>>> For best usability I am wondering if this should be an option, but if
>>>> it is it should be on by default. Thoughts?
>>>>
>>>> Gary
>>>>
>>>>
>>>> On Mon, May 19, 2014 at 9:42 PM, Gary Gregory <ga...@gmail.com>wrote:
>>>>
>>>>> On Mon, May 19, 2014 at 9:37 PM, Ralph Goers <
>>>>> ralph.goers@dslextreme.com> wrote:
>>>>>
>>>>>> It sounds like you want that in the header of the file?  That sounds
>>>>>> like an extension of what PatternLayout currently does. You would just want
>>>>>> to set the header to include the pattern.  Of course, this doesn’t apply to
>>>>>> Appenders that use some other layout.
>>>>>>
>>>>>
>>>>> Yes in the header. whatever a header means for a text file appender
>>>>> for example, maybe it is a "comment" like a comment in a property file: #
>>>>> my format.
>>>>>
>>>>> This only needs to apply to "unstructured" layouts, which are all text
>>>>> based layouts, like the File and Console, I think these all share a
>>>>> streaming super class/manager. For a database appender and other structured
>>>>> layouts (XML, JSON, and so on), this does not make sense.
>>>>>
>>>>> Gary
>>>>>
>>>>> Gary
>>>>>
>>>>>>
>>>>>> Ralph
>>>>>>
>>>>>> On May 19, 2014, at 12:47 PM, Gary Gregory <ga...@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>> I get logs from users that are files, which is nice.
>>>>>>
>>>>>> I'd like the log to have a line that shows the conversion pattern
>>>>>> used to create the log events.
>>>>>>
>>>>>> This would let me create a nice color filter in our tools.
>>>>>>
>>>>>> Yes, I know users could use some kind of structured appender in
>>>>>> addition to a log file, but they won't for my convenience...
>>>>>>
>>>>>> So I wonder if we could have setting for this? Our tools create the
>>>>>> config, so we could turn it on no matter what conversion pattern they use.
>>>>>>
>>>>>> Gary
>>>>>>
>>>>>> --
>>>>>> 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
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> 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
>>>
>>>
>>>
>>
>>
>> --
>> 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
>

Re: Consuming logs

Posted by Gary Gregory <ga...@gmail.com>.
How about this hack for PatterLayout:

    @Override
    public byte[] getHeader() {
        byte[] myHeader = super.getHeader();
        final Charset cs = getCharset();
        String strHeader = "# Conversion pattern: " +
this.conversionPattern;
        if (myHeader != null) {
            strHeader = config.getStrSubstitutor().replace(new
String(myHeader, cs)) + Constants.LINE_SEPARATOR + strHeader;
        }
        return strHeader.getBytes(cs);
    }

?

Gary


On Tue, May 20, 2014 at 3:34 PM, Gary Gregory <ga...@gmail.com>wrote:

> On Tue, May 20, 2014 at 2:46 PM, Ralph Goers <ra...@dslextreme.com>wrote:
>
>> You could implement a lookup but both the syntax of how it would be
>> specified and how it would work would be odd.  Or you could implement a
>> PatternConverter while would allow you do invoke PatternParser.parse, but
>> that would also be awkward as they typically think they are working with a
>> LogEvent.
>>
>
> So, two odd possible solutions, not a great smell.
>
> How do you (or anyone else ;-) see this done well?
>
> Gary
>
>
>> Note that what you have below - %pattern - doesn’t match with how Lookups
>> work.
>>
>
> Check, that was just a placeholder string.
>
> Gary
>
>>
>> Ralph
>>
>> On May 20, 2014, at 10:48 AM, Gary Gregory <ga...@gmail.com>
>> wrote:
>>
>> I was thinking of experimenting with this in PatternLayout:
>>
>>     @Override
>>     public byte[] getHeader() {
>>         byte [] header = super.getHeader();
>>         if (header != null) {
>>             return config.getStrSubstitutor().replace(new String(header,
>> getCharset())).getBytes(getCharset());
>>         }
>>         return header;
>>     }
>>
>> Why not support this with a marker like %pattern (of whatever). But how
>> can we tell the config's StrSubstitor about this layout's pattern string?
>>
>> In the ctor we could do:
>>
>> this.config = config;
>> this.config.getStrSubstitutor().getStrLookup().put("pattern", pattern);
>>
>> But StrLookup does not support put(String, String) of course...
>>
>> What would be a supported way to do this or do we need to tweak things a
>> bit?
>>
>> Gary
>>
>>
>>
>>
>>
>>
>> On Tue, May 20, 2014 at 9:27 AM, Gary Gregory <ga...@gmail.com>wrote:
>>
>>> For best usability I am wondering if this should be an option, but if it
>>> is it should be on by default. Thoughts?
>>>
>>> Gary
>>>
>>>
>>> On Mon, May 19, 2014 at 9:42 PM, Gary Gregory <ga...@gmail.com>wrote:
>>>
>>>> On Mon, May 19, 2014 at 9:37 PM, Ralph Goers <
>>>> ralph.goers@dslextreme.com> wrote:
>>>>
>>>>> It sounds like you want that in the header of the file?  That sounds
>>>>> like an extension of what PatternLayout currently does. You would just want
>>>>> to set the header to include the pattern.  Of course, this doesn’t apply to
>>>>> Appenders that use some other layout.
>>>>>
>>>>
>>>> Yes in the header. whatever a header means for a text file appender for
>>>> example, maybe it is a "comment" like a comment in a property file: # my
>>>> format.
>>>>
>>>> This only needs to apply to "unstructured" layouts, which are all text
>>>> based layouts, like the File and Console, I think these all share a
>>>> streaming super class/manager. For a database appender and other structured
>>>> layouts (XML, JSON, and so on), this does not make sense.
>>>>
>>>> Gary
>>>>
>>>> Gary
>>>>
>>>>>
>>>>> Ralph
>>>>>
>>>>> On May 19, 2014, at 12:47 PM, Gary Gregory <ga...@gmail.com>
>>>>> wrote:
>>>>>
>>>>> I get logs from users that are files, which is nice.
>>>>>
>>>>> I'd like the log to have a line that shows the conversion pattern used
>>>>> to create the log events.
>>>>>
>>>>> This would let me create a nice color filter in our tools.
>>>>>
>>>>> Yes, I know users could use some kind of structured appender in
>>>>> addition to a log file, but they won't for my convenience...
>>>>>
>>>>> So I wonder if we could have setting for this? Our tools create the
>>>>> config, so we could turn it on no matter what conversion pattern they use.
>>>>>
>>>>> Gary
>>>>>
>>>>> --
>>>>> 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
>>>>
>>>
>>>
>>>
>>> --
>>> 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
>>
>>
>>
>
>
> --
> 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

Re: Consuming logs

Posted by Gary Gregory <ga...@gmail.com>.
On Tue, May 20, 2014 at 2:46 PM, Ralph Goers <ra...@dslextreme.com>wrote:

> You could implement a lookup but both the syntax of how it would be
> specified and how it would work would be odd.  Or you could implement a
> PatternConverter while would allow you do invoke PatternParser.parse, but
> that would also be awkward as they typically think they are working with a
> LogEvent.
>

So, two odd possible solutions, not a great smell.

How do you (or anyone else ;-) see this done well?

Gary


> Note that what you have below - %pattern - doesn’t match with how Lookups
> work.
>

Check, that was just a placeholder string.

Gary

>
> Ralph
>
> On May 20, 2014, at 10:48 AM, Gary Gregory <ga...@gmail.com> wrote:
>
> I was thinking of experimenting with this in PatternLayout:
>
>     @Override
>     public byte[] getHeader() {
>         byte [] header = super.getHeader();
>         if (header != null) {
>             return config.getStrSubstitutor().replace(new String(header,
> getCharset())).getBytes(getCharset());
>         }
>         return header;
>     }
>
> Why not support this with a marker like %pattern (of whatever). But how
> can we tell the config's StrSubstitor about this layout's pattern string?
>
> In the ctor we could do:
>
> this.config = config;
> this.config.getStrSubstitutor().getStrLookup().put("pattern", pattern);
>
> But StrLookup does not support put(String, String) of course...
>
> What would be a supported way to do this or do we need to tweak things a
> bit?
>
> Gary
>
>
>
>
>
>
> On Tue, May 20, 2014 at 9:27 AM, Gary Gregory <ga...@gmail.com>wrote:
>
>> For best usability I am wondering if this should be an option, but if it
>> is it should be on by default. Thoughts?
>>
>> Gary
>>
>>
>> On Mon, May 19, 2014 at 9:42 PM, Gary Gregory <ga...@gmail.com>wrote:
>>
>>> On Mon, May 19, 2014 at 9:37 PM, Ralph Goers <ralph.goers@dslextreme.com
>>> > wrote:
>>>
>>>> It sounds like you want that in the header of the file?  That sounds
>>>> like an extension of what PatternLayout currently does. You would just want
>>>> to set the header to include the pattern.  Of course, this doesn’t apply to
>>>> Appenders that use some other layout.
>>>>
>>>
>>> Yes in the header. whatever a header means for a text file appender for
>>> example, maybe it is a "comment" like a comment in a property file: # my
>>> format.
>>>
>>> This only needs to apply to "unstructured" layouts, which are all text
>>> based layouts, like the File and Console, I think these all share a
>>> streaming super class/manager. For a database appender and other structured
>>> layouts (XML, JSON, and so on), this does not make sense.
>>>
>>> Gary
>>>
>>> Gary
>>>
>>>>
>>>> Ralph
>>>>
>>>> On May 19, 2014, at 12:47 PM, Gary Gregory <ga...@gmail.com>
>>>> wrote:
>>>>
>>>> I get logs from users that are files, which is nice.
>>>>
>>>> I'd like the log to have a line that shows the conversion pattern used
>>>> to create the log events.
>>>>
>>>> This would let me create a nice color filter in our tools.
>>>>
>>>> Yes, I know users could use some kind of structured appender in
>>>> addition to a log file, but they won't for my convenience...
>>>>
>>>> So I wonder if we could have setting for this? Our tools create the
>>>> config, so we could turn it on no matter what conversion pattern they use.
>>>>
>>>> Gary
>>>>
>>>> --
>>>> 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
>>>
>>
>>
>>
>> --
>> 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
>
>
>


-- 
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

Re: Consuming logs

Posted by Ralph Goers <ra...@dslextreme.com>.
You could implement a lookup but both the syntax of how it would be specified and how it would work would be odd.  Or you could implement a PatternConverter while would allow you do invoke PatternParser.parse, but that would also be awkward as they typically think they are working with a LogEvent.  

Note that what you have below - %pattern - doesn’t match with how Lookups work.

Ralph

On May 20, 2014, at 10:48 AM, Gary Gregory <ga...@gmail.com> wrote:

> I was thinking of experimenting with this in PatternLayout:
> 
>     @Override
>     public byte[] getHeader() {
>         byte [] header = super.getHeader();
>         if (header != null) {
>             return config.getStrSubstitutor().replace(new String(header, getCharset())).getBytes(getCharset());
>         }
>         return header;
>     }
> 
> Why not support this with a marker like %pattern (of whatever). But how can we tell the config's StrSubstitor about this layout's pattern string?
> 
> In the ctor we could do:
> 
> this.config = config;
> this.config.getStrSubstitutor().getStrLookup().put("pattern", pattern);
> 
> But StrLookup does not support put(String, String) of course...
> 
> What would be a supported way to do this or do we need to tweak things a bit?
> 
> Gary
> 
> 
> 
> 
> 
> 
> On Tue, May 20, 2014 at 9:27 AM, Gary Gregory <ga...@gmail.com> wrote:
> For best usability I am wondering if this should be an option, but if it is it should be on by default. Thoughts?
> 
> Gary
> 
> 
> On Mon, May 19, 2014 at 9:42 PM, Gary Gregory <ga...@gmail.com> wrote:
> On Mon, May 19, 2014 at 9:37 PM, Ralph Goers <ra...@dslextreme.com> wrote:
> It sounds like you want that in the header of the file?  That sounds like an extension of what PatternLayout currently does. You would just want to set the header to include the pattern.  Of course, this doesn’t apply to Appenders that use some other layout.
> 
> Yes in the header. whatever a header means for a text file appender for example, maybe it is a "comment" like a comment in a property file: # my format.
> 
> This only needs to apply to "unstructured" layouts, which are all text based layouts, like the File and Console, I think these all share a streaming super class/manager. For a database appender and other structured layouts (XML, JSON, and so on), this does not make sense.
> 
> Gary
> 
> Gary
> 
> Ralph
> 
> On May 19, 2014, at 12:47 PM, Gary Gregory <ga...@gmail.com> wrote:
> 
>> I get logs from users that are files, which is nice.
>> 
>> I'd like the log to have a line that shows the conversion pattern used to create the log events.
>> 
>> This would let me create a nice color filter in our tools.
>> 
>> Yes, I know users could use some kind of structured appender in addition to a log file, but they won't for my convenience...
>> 
>> So I wonder if we could have setting for this? Our tools create the config, so we could turn it on no matter what conversion pattern they use.
>> 
>> Gary
>> 
>> -- 
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>> Java Persistence with Hibernate, Second Edition
>> JUnit in Action, Second Edition
>> Spring Batch in Action
>> 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
> JUnit in Action, Second Edition
> Spring Batch in Action
> 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
> JUnit in Action, Second Edition
> Spring Batch in Action
> 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
> JUnit in Action, Second Edition
> Spring Batch in Action
> Blog: http://garygregory.wordpress.com 
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory


Re: Consuming logs

Posted by Gary Gregory <ga...@gmail.com>.
I was thinking of experimenting with this in PatternLayout:

    @Override
    public byte[] getHeader() {
        byte [] header = super.getHeader();
        if (header != null) {
            return config.getStrSubstitutor().replace(new String(header,
getCharset())).getBytes(getCharset());
        }
        return header;
    }

Why not support this with a marker like %pattern (of whatever). But how can
we tell the config's StrSubstitor about this layout's pattern string?

In the ctor we could do:

this.config = config;
this.config.getStrSubstitutor().getStrLookup().put("pattern", pattern);

But StrLookup does not support put(String, String) of course...

What would be a supported way to do this or do we need to tweak things a
bit?

Gary






On Tue, May 20, 2014 at 9:27 AM, Gary Gregory <ga...@gmail.com>wrote:

> For best usability I am wondering if this should be an option, but if it
> is it should be on by default. Thoughts?
>
> Gary
>
>
> On Mon, May 19, 2014 at 9:42 PM, Gary Gregory <ga...@gmail.com>wrote:
>
>> On Mon, May 19, 2014 at 9:37 PM, Ralph Goers <ra...@dslextreme.com>wrote:
>>
>>> It sounds like you want that in the header of the file?  That sounds
>>> like an extension of what PatternLayout currently does. You would just want
>>> to set the header to include the pattern.  Of course, this doesn’t apply to
>>> Appenders that use some other layout.
>>>
>>
>> Yes in the header. whatever a header means for a text file appender for
>> example, maybe it is a "comment" like a comment in a property file: # my
>> format.
>>
>> This only needs to apply to "unstructured" layouts, which are all text
>> based layouts, like the File and Console, I think these all share a
>> streaming super class/manager. For a database appender and other structured
>> layouts (XML, JSON, and so on), this does not make sense.
>>
>> Gary
>>
>> Gary
>>
>>>
>>> Ralph
>>>
>>> On May 19, 2014, at 12:47 PM, Gary Gregory <ga...@gmail.com>
>>> wrote:
>>>
>>> I get logs from users that are files, which is nice.
>>>
>>> I'd like the log to have a line that shows the conversion pattern used
>>> to create the log events.
>>>
>>> This would let me create a nice color filter in our tools.
>>>
>>> Yes, I know users could use some kind of structured appender in addition
>>> to a log file, but they won't for my convenience...
>>>
>>> So I wonder if we could have setting for this? Our tools create the
>>> config, so we could turn it on no matter what conversion pattern they use.
>>>
>>> Gary
>>>
>>> --
>>> 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
>>
>
>
>
> --
> 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

Re: Consuming logs

Posted by Gary Gregory <ga...@gmail.com>.
For best usability I am wondering if this should be an option, but if it is
it should be on by default. Thoughts?

Gary


On Mon, May 19, 2014 at 9:42 PM, Gary Gregory <ga...@gmail.com>wrote:

> On Mon, May 19, 2014 at 9:37 PM, Ralph Goers <ra...@dslextreme.com>wrote:
>
>> It sounds like you want that in the header of the file?  That sounds like
>> an extension of what PatternLayout currently does. You would just want to
>> set the header to include the pattern.  Of course, this doesn’t apply to
>> Appenders that use some other layout.
>>
>
> Yes in the header. whatever a header means for a text file appender for
> example, maybe it is a "comment" like a comment in a property file: # my
> format.
>
> This only needs to apply to "unstructured" layouts, which are all text
> based layouts, like the File and Console, I think these all share a
> streaming super class/manager. For a database appender and other structured
> layouts (XML, JSON, and so on), this does not make sense.
>
> Gary
>
> Gary
>
>>
>> Ralph
>>
>> On May 19, 2014, at 12:47 PM, Gary Gregory <ga...@gmail.com>
>> wrote:
>>
>> I get logs from users that are files, which is nice.
>>
>> I'd like the log to have a line that shows the conversion pattern used to
>> create the log events.
>>
>> This would let me create a nice color filter in our tools.
>>
>> Yes, I know users could use some kind of structured appender in addition
>> to a log file, but they won't for my convenience...
>>
>> So I wonder if we could have setting for this? Our tools create the
>> config, so we could turn it on no matter what conversion pattern they use.
>>
>> Gary
>>
>> --
>> 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
>



-- 
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

Re: Consuming logs

Posted by Gary Gregory <ga...@gmail.com>.
On Mon, May 19, 2014 at 9:37 PM, Ralph Goers <ra...@dslextreme.com>wrote:

> It sounds like you want that in the header of the file?  That sounds like
> an extension of what PatternLayout currently does. You would just want to
> set the header to include the pattern.  Of course, this doesn’t apply to
> Appenders that use some other layout.
>

Yes in the header. whatever a header means for a text file appender for
example, maybe it is a "comment" like a comment in a property file: # my
format.

This only needs to apply to "unstructured" layouts, which are all text
based layouts, like the File and Console, I think these all share a
streaming super class/manager. For a database appender and other structured
layouts (XML, JSON, and so on), this does not make sense.

Gary

Gary

>
> Ralph
>
> On May 19, 2014, at 12:47 PM, Gary Gregory <ga...@gmail.com> wrote:
>
> I get logs from users that are files, which is nice.
>
> I'd like the log to have a line that shows the conversion pattern used to
> create the log events.
>
> This would let me create a nice color filter in our tools.
>
> Yes, I know users could use some kind of structured appender in addition
> to a log file, but they won't for my convenience...
>
> So I wonder if we could have setting for this? Our tools create the
> config, so we could turn it on no matter what conversion pattern they use.
>
> Gary
>
> --
> 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

Re: Consuming logs

Posted by Ralph Goers <ra...@dslextreme.com>.
It sounds like you want that in the header of the file?  That sounds like an extension of what PatternLayout currently does. You would just want to set the header to include the pattern.  Of course, this doesn’t apply to Appenders that use some other layout.

Ralph

On May 19, 2014, at 12:47 PM, Gary Gregory <ga...@gmail.com> wrote:

> I get logs from users that are files, which is nice.
> 
> I'd like the log to have a line that shows the conversion pattern used to create the log events.
> 
> This would let me create a nice color filter in our tools.
> 
> Yes, I know users could use some kind of structured appender in addition to a log file, but they won't for my convenience...
> 
> So I wonder if we could have setting for this? Our tools create the config, so we could turn it on no matter what conversion pattern they use.
> 
> Gary
> 
> -- 
> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
> Java Persistence with Hibernate, Second Edition
> JUnit in Action, Second Edition
> Spring Batch in Action
> Blog: http://garygregory.wordpress.com 
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory


Re: Consuming logs

Posted by Paul Benedict <pb...@apache.org>.
Gary, maybe log4j could spit out some of its own configuration information
into the logs when it starts up? Set DEBUG for a certain log4j class --
what a cool enhancement.


Cheers,
Paul


On Mon, May 19, 2014 at 2:47 PM, Gary Gregory <ga...@gmail.com>wrote:

> I get logs from users that are files, which is nice.
>
> I'd like the log to have a line that shows the conversion pattern used to
> create the log events.
>
> This would let me create a nice color filter in our tools.
>
> Yes, I know users could use some kind of structured appender in addition
> to a log file, but they won't for my convenience...
>
> So I wonder if we could have setting for this? Our tools create the
> config, so we could turn it on no matter what conversion pattern they use.
>
> Gary
>
> --
> 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
>