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 <garydgreg...@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 <garydgreg...@gmail.com>wrote: > >> On Mon, May 19, 2014 at 9:37 PM, Ralph Goers >> <ralph.go...@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 <garydgreg...@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: garydgreg...@gmail.com | ggreg...@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: garydgreg...@gmail.com | ggreg...@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: garydgreg...@gmail.com | ggreg...@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: garydgreg...@gmail.com | ggreg...@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