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 2016/03/08 20:28:42 UTC
version 1.2 vs 2 properties files thoughts
I initially thought of adding a
version=2
to our Log4j 2 properties file format.
I am experimenting with code to read in 1.2 properties files to configure
Log4j 2, and I'd like an easy way to tell if I'm dealing with a version 2
properly file. I thought that would be cleaner that looking for
"log4j.rootLogger" and deciding that means 1.2.
I was thinking of putting a new ConfigurationFactory in log4j-api which
means it would kick in automatically if on the CP. It could look for a
log4j.rootLogger and do nothing if it does not find one.
But would Log4j 2 then init itself correctly?
I'm only thinking simple cases at first, you gotta start somewhere: Console.
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: version 1.2 vs 2 properties files thoughts
Posted by Ralph Goers <ra...@dslextreme.com>.
You should be able to tell just by looking for “log4j.” as the prefix. Log4j 2 doesn’t do that anywhere.
Ralph
> On Mar 8, 2016, at 12:44 PM, Gary Gregory <ga...@gmail.com> wrote:
>
> Yes, I can make it work by looking for "log4j.rootLogger" for example, and I guess if the v2 format changes we can add a property _then_ that says 2.6 or 3.0 or whatever.
>
> Gary
>
> On Tue, Mar 8, 2016 at 11:39 AM, Matt Sicker <boards@gmail.com <ma...@gmail.com>> wrote:
> Well, if the new config format doesn't prefix anything with log4j., then that sounds like a safe way to check the version. Adding a version wouldn't work with previously-written formats, so we'd still have to guess.
>
> On 8 March 2016 at 13:28, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
> I initially thought of adding a
>
> version=2
>
> to our Log4j 2 properties file format.
>
> I am experimenting with code to read in 1.2 properties files to configure Log4j 2, and I'd like an easy way to tell if I'm dealing with a version 2 properly file. I thought that would be cleaner that looking for "log4j.rootLogger" and deciding that means 1.2.
>
> I was thinking of putting a new ConfigurationFactory in log4j-api which means it would kick in automatically if on the CP. It could look for a log4j.rootLogger and do nothing if it does not find one.
>
> But would Log4j 2 then init itself correctly?
>
> I'm only thinking simple cases at first, you gotta start somewhere: Console.
>
> Gary
>
> --
> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org <ma...@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 <http://garygregory.wordpress.com/>
> Home: http://garygregory.com/ <http://garygregory.com/>
> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
>
>
> --
> Matt Sicker <boards@gmail.com <ma...@gmail.com>>
>
>
>
> --
> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org <ma...@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 <http://garygregory.wordpress.com/>
> Home: http://garygregory.com/ <http://garygregory.com/>
> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
Re: version 1.2 vs 2 properties files thoughts
Posted by Gary Gregory <ga...@gmail.com>.
Yes, I can make it work by looking for "log4j.rootLogger" for example, and
I guess if the v2 format changes we can add a property _then_ that says 2.6
or 3.0 or whatever.
Gary
On Tue, Mar 8, 2016 at 11:39 AM, Matt Sicker <bo...@gmail.com> wrote:
> Well, if the new config format doesn't prefix anything with log4j., then
> that sounds like a safe way to check the version. Adding a version wouldn't
> work with previously-written formats, so we'd still have to guess.
>
> On 8 March 2016 at 13:28, Gary Gregory <ga...@gmail.com> wrote:
>
>> I initially thought of adding a
>>
>> version=2
>>
>> to our Log4j 2 properties file format.
>>
>> I am experimenting with code to read in 1.2 properties files to configure
>> Log4j 2, and I'd like an easy way to tell if I'm dealing with a version 2
>> properly file. I thought that would be cleaner that looking for
>> "log4j.rootLogger" and deciding that means 1.2.
>>
>> I was thinking of putting a new ConfigurationFactory in log4j-api which
>> means it would kick in automatically if on the CP. It could look for a
>> log4j.rootLogger and do nothing if it does not find one.
>>
>> But would Log4j 2 then init itself correctly?
>>
>> I'm only thinking simple cases at first, you gotta start somewhere:
>> Console.
>>
>> 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
>>
>
>
>
> --
> Matt Sicker <bo...@gmail.com>
>
--
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: version 1.2 vs 2 properties files thoughts
Posted by Matt Sicker <bo...@gmail.com>.
Well, if the new config format doesn't prefix anything with log4j., then
that sounds like a safe way to check the version. Adding a version wouldn't
work with previously-written formats, so we'd still have to guess.
On 8 March 2016 at 13:28, Gary Gregory <ga...@gmail.com> wrote:
> I initially thought of adding a
>
> version=2
>
> to our Log4j 2 properties file format.
>
> I am experimenting with code to read in 1.2 properties files to configure
> Log4j 2, and I'd like an easy way to tell if I'm dealing with a version 2
> properly file. I thought that would be cleaner that looking for
> "log4j.rootLogger" and deciding that means 1.2.
>
> I was thinking of putting a new ConfigurationFactory in log4j-api which
> means it would kick in automatically if on the CP. It could look for a
> log4j.rootLogger and do nothing if it does not find one.
>
> But would Log4j 2 then init itself correctly?
>
> I'm only thinking simple cases at first, you gotta start somewhere:
> Console.
>
> 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
>
--
Matt Sicker <bo...@gmail.com>